Subject: RE: [xsl] XSLT FAQ? and really questions From: "Jeremy E. Denton" <jdenton@xxxxxxxxxxxxx> Date: Fri, 20 Apr 2001 13:59:16 -0700 |
Hey Dan, This is a really great example. It's exactly what I want to do. I am have a little trouble seperating out the dynamically generating element names and how the IDs get grouped together. I didn't intend on dynamically generating the IDs. I had assumed they were fixed. Could you clarify this for me? XSLT definately has a steep learning curve. Jeremy > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Dan Diebolt > Sent: Friday, 20 April 2001 12:08 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] XSLT FAQ? and really questions > > > 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 > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT FAQ? and really ques, Dan Diebolt | Thread | Re: [xsl] XSLT FAQ? and really ques, David Carlisle |
[xsl] <XSL:OUTPUT METHOD>, Kevin_Gutch | Date | RE: [xsl]Jumping out a loop AND Sta, David_Marston |
Month |