[xsl] Re: XML transformation using XSL - Urgent, Please HELP!! Thanks

Subject: [xsl] Re: XML transformation using XSL - Urgent, Please HELP!! Thanks
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Fri, 27 Apr 2001 23:14:38 -0700 (PDT)
You probably should drop xml-dev (that list is for arguing about
xml) and post your questions to xsl-list only.

I isn't clear what pattern your ellipses continue:

 <PRODUCT xml:lang="en">


However, my guess is that you have some type of repeating 'row' consisting
of fields but without the row as a containing element. In other words, with
regard to the missing "rows" your XML looks like this:

 <a>1</a> <b>apple</b>  <c>$1.29</c>
 <a>2</a> <b>cherry</b> <c>$1.69</c>
 <a>3</a> <b>grape</b>  <c>$1.15</c>

instead of this:

 <row> <a>1</a> <b>apple</b>  <c>$1.29</c> </row>
 <row> <a>2</a> <b>cherry</b> <c>$1.69</c> </row>
 <row> <a>3</a> <b>grape</b>  <c>$1.15</c> </row>

in which case it is best to use position() and modulo to address
children of PRODUCTS. So you should be able to apply the technique
demonstrated with the enclosed XML and XSL.



File: NoRecordsOnlyFields.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="NoRecordsOnlyFields.xsl"?>

 <a>1</a> <b>apple</b>  <c>$1.29</c>
 <a>2</a> <b>cherry</b> <c>$1.69</c>
 <a>3</a> <b>grape</b>  <c>$1.15</c>

#File: NoRecordsOnlyFields.xsl<?xml version="1.0"?>

<xsl:stylesheet version="1.0" 
 <xsl:output indent="yes"/>
 <xsl:param name="n"/>
  <xsl:template match="/">
   <xsl:apply-templates select="root"/>
 <xsl:template match="root">
   <xsl:for-each select="*[position() mod $n = 1]">
    <xsl:for-each select=".|following-sibling::*[position() &lt; $n]">
     <xsl:copy-of select="."/>

Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread