This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XSL Line Breaks/Indentation - Please !!!


| 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">&lt;PRODUCT
xml:lang="</xsl:text>
|   <xsl:value-of select="$attribValue"/>
|   <xsl:text disable-output-escaping="yes">"&gt;</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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]