views:

39

answers:

2

I thought i'd use a macro to speed up writing <xsl:choose> blocks.

DTE.ActiveDocument.Selection.Text = "<xsl:choose>"
DTE.ActiveDocument.Selection.NewLine()

gives me (thanks to auto complete)

<xsl:choose>

</xsl:choose>

however

DTE.ActiveDocument.Selection.Text = "<xsl:choose>"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "<xsl:when test=""true()"">"

gives

<xsl:choose>
  <xsl:when test="true()"></xsl:when>"
</xsl:choose>

in the editor.

Where is that extra " coming from??

Cheers

+1  A: 

What happens when you escape the "" with \"

DTE.ActiveDocument.Selection.Text = "<xsl:when test=\"true()\"/>"
MoJo2600
A: 

Hehe, it's the autocomplete. When the macro types the = symbol the ide adds the quote marks and moves the cursor, then the macro continues typing where i'm not expecting it to be.

D'oh.

DTE.ActiveDocument.Selection.Text = "<xsl:choose>"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "<xsl:when test=true()"
DTE.ActiveDocument.Selection.EndOfLine()
DTE.ActiveDocument.Selection.Text = ">"
DTE.ActiveDocument.Selection.NewLine()
runrunraygun