[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: XSL Line Breaks/Indentation - Please !!!
From: "Steve Muench" <Steve.Muench@xxxxxxxxxx>
Date: Thu, 26 Apr 2001 22:28:14 -0700
xsl line breaks
| 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.