Subject: [xsl] Re: XSL Line Breaks/Indentation - Please !!! From: "Steve Muench" <Steve.Muench@xxxxxxxxxx> Date: Thu, 26 Apr 2001 22:28:14 -0700 |
| And I use the following XSL to convert this to another XML: | | <?xml version="1.0"?> | <xsl:stylesheet version="1.0" : | <xsl:text disable-output-escaping="yes"><PRODUCT xml:lang="</xsl:text> | <xsl:value-of select="$attribValue"/> | <xsl:text disable-output-escaping="yes">"></xsl:text> A stylesheet like this might work better for you: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="PRODUCTS"> <xsl:copy> <xsl:apply-templates select="PRODUCT"/> </xsl:copy> </xsl:template> <xsl:template match="PRODUCT"> <xsl:variable name="lang" select="@xml:lang"/> <PRODUCT xml:lang="{$lang}"> <xsl:copy-of select="PRODUCTID"/> <xsl:copy-of select="PRODUCTNAME"/> <xsl:copy-of select="MANUFACTURERPRODUCTNAME"/> <xsl:copy-of select="BRANDNAME"/> <xsl:for-each select="EXTRAID"> <PRODUCTID QUALIFIER="{following-sibling::*}"> <xsl:value-of select="."/> </PRODUCTID> </xsl:for-each> <xsl:for-each select="KEYWORD"> <KEYWORD xml:lang="{$lang}"> <xsl:value-of select="."/> </KEYWORD> </xsl:for-each> </PRODUCT> </xsl:template> </xsl:stylesheet> When you find yourself using disable-output-escaping="yes" to construct element markup like angle-brackets, then it should be a sign that there's probably an easier way since XSLT is designed to make it really easy to construct elements and attributes in the output. I'm not exactly sure if the following-sibling::* is what you want, but this cleaned up version of your stylesheet should get you going in the right direction. ______________________________________________________________ Steve Muench, Lead XML Evangelist & Consulting Product Manager BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG Author "Building Oracle XML Applications", O'Reilly http://www.oreilly.com/catalog/orxmlapp/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] not selecting child eleme, Michael Kay | Thread | [xsl] Re: XSL Line Breaks/Indentati, David Carlisle |
RE: [xsl] not selecting child eleme, Jarno Elovirta | Date | Re: [xsl] sorting product descripti, Tobias Reif |
Month |