Subject: [xsl] seemingly simple transform, need idea how to do it. From: "Carter, Will" <WCarter@xxxxxxxxxxxxxxxx> Date: Tue, 8 Oct 2002 08:48:07 -0500 |
Here is my XML --------------------------------------------- <people> <person firstName="Johnny"> <date day="2002-01-01"> <funThing>Ate Pizza</funThing> <badThing>Hit Brother</badThing> </date> <date day="2002-02-01"> <funThing>Bought Bike</funThing> <badThing>Stole Candy</badThing> </date> <date day="2002-03-01"> <funThing>Ran in Park</funThing> <badThing>Skipped class</badThing> </date> </person> <person firstName="Billy"> <date day="2002-01-01"> <funThing>Swam in lake</funThing> <badThing>Told a lie</badThing> </date> <date day="2002-02-01"> <funThing>Jumped on Tramp</funThing> <badThing>Hid valuables</badThing> </date> <date day="2002-03-01"> <funThing>Visited Disney</funThing> <badThing>Cussed</badThing> </date> </person> </people> --------------------------------------------- Here is what I want in my output: --------------------------------------------- Johnny FunThing Johnny BadThing Billy FunThing Billy BadThing 2002-01-01 Ate Pizza Hit Brother Swam in lake Told a lie 2002-02-01 Bought Bike Stole Candy Jumped on Tramp Hid valuables 2002-03-01 Ran in Park Skipped class Visited Disney Cussed --------------------------------------------- Here is my xsl that kinda works (shows correct output but sorting doesn't work): --------------------------------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <table border="1"> <tr> <td></td> <td>Johnny FunThing</td> <td>Johnny BadThing</td> <td>Billy FunThing</td> <td>Billy BadThing</td> </tr> <xsl:for-each select="people/person/date[../@firstName = 'Johnny']"> <xsl:sort select="@day" order="ascending" data-type="text"/> <xsl:variable name="pos" select="position()"/> <tr> <td><xsl:value-of select="@day"/></td> <td><xsl:value-of select="funThing"/></td> <td><xsl:value-of select="badThing"/></td> <td><xsl:for-each select="../../person/date[../@firstName = 'Billy'][position() = $pos]"><xsl:value-of select="funThing"/></xsl:for-each></td> <td><xsl:for-each select="../../person/date[../@firstName = 'Billy'][position() = $pos]"><xsl:value-of select="badThing"/></xsl:for-each></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> --------------------------------------------- I want to be able to sort on the Billy funThing or Billy badThing columns. Seems like I am doing too much to set variable with position, jump out of that loop to get the Billy contents. any help would be appreciated. thanks, will XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Grouping and sorting usin, Dimitre Novatchev | Thread | Re: [xsl] seemingly simple transfor, Trevor Nash |
Re: [xsl] data structure in xslt?, Trevor Nash | Date | RE: [xsl]Clarify Add an element to , LVanvleet |
Month |