|
Subject: Re: [xsl] XSLT FAQ? and really questions From: Dan Diebolt <dandiebolt@xxxxxxxxx> Date: Fri, 20 Apr 2001 12:07:33 -0700 (PDT) |
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"><</xsl:text>
<xsl:value-of select="$x"/>
<xsl:text disable-output-escaping="yes">></xsl:text>
<xsl:value-of select="."/>
<xsl:text disable-output-escaping="yes"></</xsl:text>
<xsl:value-of select="$x"/>
<xsl:text disable-output-escaping="yes">></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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSLT FAQ? and really ques, RSuiter | Thread | RE: [xsl] XSLT FAQ? and really ques, Jeremy E. Denton |
| RE: [xsl]Jumping out a loop AND Sta, Patrick Moore | Date | Re: [xsl] docbook.xsl by nwalsh and, Dan Diebolt |
| Month |