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

Re: XSLT FAQ? and really questions

Subject: Re: XSLT FAQ? and really questions
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Fri, 20 Apr 2001 12:07:33 -0700 (PDT)
id1 id2 tags
It is a grouping problem. Search the archives for examples.

I think this could be improved but for a shrink wrap answer 
start with this. I found this a bit challanging myself. 
It produces the following output:

<?xml version="1.0" encoding="utf-8"?>
<idsets>
 <ID1>123</ID1>
 <ID1>345</ID1>
 <ID2>234</ID2>
 <ID2>456</ID2>
</idsets>

Now that I format the email for the list, I see I left out the
<ID1List> tags - but they can by build similar to the <ID1>
tags. I will leave this for the student. ;)

Regards,

Dan
----------------------------

File: XSLT20April2001.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="XSLT20April2001.xsl"?>
<records>
 <record>
  <ID1>123</ID1>
  <ID2>234</ID2>
 </record>
 <record>
  <ID1>345</ID1>
  <ID2>456</ID2>
 </record>
</records>

File: XSLT20April2001.xsl
 <xsl:key name="IDs" match="records/record/*" use="name()"/>
 <xsl:template match="/">
  <xsl:apply-templates select="records"/>
 </xsl:template>
 <xsl:template match="records">
  <xsl:element name="idsets">
   <xsl:for-each
select="record/*[generate-id(.)=generate-id(key('IDs',name()))]">
    <xsl:variable name="x" select="name()"/>
    <xsl:for-each select="/records/record/*[name()=$x]">
     <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
     <xsl:value-of select="$x"/>
     <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
     <xsl:value-of select="."/>
     <xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
     <xsl:value-of select="$x"/>
     <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
    </xsl:for-each>
   </xsl:for-each>
  </xsl:element>
 </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.