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

Re: XML transformation using XSL - Urgent, Please HELP

Subject: Re: XML transformation using XSL - Urgent, Please HELP!! Thanks
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Fri, 27 Apr 2001 23:14:38 -0700 (PDT)
diebolt products
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:

<PRODUCTS>
 <PRODUCT xml:lang="en">
  <PRODUCTID>1234</PRODUCTID>     
  <MANUFACTURERCOMPANYID>1m1</MANUFACTURERCOMPANYID>
  <MANUFACTURERCOMPANYNAME>Manufactorer name</MANUFACTURERCOMPANYNAME>
  <PRODUCTQUALIFIER>MK</PRODUCTQUALIFIER>

  <MANUFACTURERCOMPANYNAME2>Manufactorer name2</MANUFACTURERCOMPANYNAME2>
  ....
  ...
  ..
  ..
 </PRODUCT>
</PRODUCTS>

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:

<root>
 <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>
</root>

instead of this:

<root>
 <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>
</root>

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.

Regards,

Dan

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

<root>
 <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>
</root>

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

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


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 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.