[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Malformed (??) XML and XML 2 SQL XSLT transformati
Hi Charles, > The lines are longer than I would like, but were necessary in order > to eliminate unwanted whitespace in the output. Use <xsl:text> around text in order to make the stylesheet look nice without passing whitespace through into the output. For example, rather than: > <xsl:template match="Orders" mode="columns">INSERT INTO orders(<xsl:for-each select="Customer/Template/Fields">"<xsl:value-of select="@FieldName" />"<xsl:if test="position() != last()">,</xsl:if></xsl:for-each>)</xsl:template> use: <xsl:template match="Orders" mode="columns"> <xsl:text>INSERT INTO orders(</xsl:text> <xsl:for-each select="Customer/Template/Fields"> <xsl:text>"</xsl:text> <xsl:value-of select="@FieldName" /> <xsl:text>"</xsl:text> <xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> <xsl:text>)</xsl:text> </xsl:template> This works because whitespace-only text nodes in the tree generated from the stylesheet document automatically get stripped, unless they appear within <xsl:text> elements. So <xsl:text> effectively delimits the text that you're interested in from the whitespace that you don't want. You can also use the concat() function in an <xsl:value-of> to reduce the verbosity and help manage whitespace: <xsl:template match="Orders" mode="columns"> <xsl:text>INSERT INTO orders(</xsl:text> <xsl:for-each select="Customer/Template/Fields"> <xsl:value-of select="concat('"', @FieldName, '"')" /> <xsl:if test="position() != last()">,</xsl:if> </xsl:for-each> <xsl:text>)</xsl:text> </xsl:template> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|