Subject: Re: [xsl] Missing nodes are ruining my sort !!!! From: "Rupert Howell" <Rupert.Howell@xxxxxxxxxxxxxx> Date: Tue, 9 Dec 2003 15:32:09 +0000 |
OK thanks for your replies, Here is more info. The XSL below will give me a table including the blank values where nodes are missing. The rows of the table are sorted by the attribute order on RESULTS/PRESENTATION/AREAS/AREA This works fine and you get (without the place names and column headers). The *s are just to highlight an empty cell. Variable1 Variable2 Variable3 North East 200 500 800 North West *** *** *** London 100 400 600 South East 300 600 900 Now imagine I want to sort the rows by variable 1 . So I would hope to see Variable1 Variable2 Variable3 London 100 400 600 North East 200 500 800 South East 300 600 900 North West *** *** *** I need to change the XPath expression in <xsl:sort select="@order" data-type="number" order="ascending"/> but I can't work the expression I need out or even if this sort of cross node sorting is even possible. This really, really is driving me mad !!!!!! Here is the XSL: <xsl:template match="/"> <table> <xsl:for-each select="//PRESENTATION/AREAS/AREA"> <xsl:sort select="@order" data-type="number" order="ascending "/> <xsl:call-template name="rows"> <xsl:with-param name="areaID" select="@areaid"/> </xsl:call-template> </xsl:for-each> </table> </xsl:template> <xsl:template name="rows"> <xsl:param name="areaID" /> <tr> <xsl:for-each select="//PRESENTATION/VARIABLES/VARIABLE"> <xsl:call-template name="cols"> <xsl:with-param name="variableID" select="@variableid" /> <xsl:with-param name="areaID" select="$areaID"/> </xsl:call-template> </xsl:for-each> </tr> </xsl:template> <xsl:template name="cols"> <xsl:param name="areaID" /> <xsl:param name="variableID" /> <td> Value = <xsl:value-of select=" //RESULTS/DATA/INSTANCE/AREAID[text()=$areaID]/../VARIABLEID[text()=$variableID]/../VALUE/text() " ></xsl:value-of> </td> </xsl:template> Here is the XML :-- <RESULTS> <PRESENTATION> <AREAS> <AREA order="3" areaid='A'>London</AREA> <AREA order="1" areaid='B'>North East</AREA> <AREA order="2" areaid='C'>North West</AREA> <AREA order="4" areaid='D'>South East</AREA> </AREAS> <VARIABLES> <VARIABLE variableid='1'>Variable1</VARIABLE> <VARIABLE variableid='2'>Variable2</VARIABLE> <VARIABLE variableid='3'>Variable3</VARIABLE> </VARIABLES> </PRESENTATION> <DATA> <INSTANCE> <AREAID>A</AREAID> <VARIABLEID>1</VARIABLEID> <VALUE>100</VALUE> </INSTANCE> <INSTANCE> <AREAID>B</AREAID> <VARIABLEID>1</VARIABLEID> <VALUE>200</VALUE> </INSTANCE> <INSTANCE> <AREAID>D</AREAID> <VARIABLEID>1</VARIABLEID> <VALUE>300</VALUE> </INSTANCE> <INSTANCE> <AREAID>A</AREAID> <VARIABLEID>2</VARIABLEID> <VALUE>400</VALUE> </INSTANCE> <INSTANCE> <AREAID>B</AREAID> <VARIABLEID>2</VARIABLEID> <VALUE>500</VALUE> </INSTANCE> <INSTANCE> <AREAID>D</AREAID> <VARIABLEID>2</VARIABLEID> <VALUE>600</VALUE> </INSTANCE> <INSTANCE> <AREAID>A</AREAID> <VARIABLEID>3</VARIABLEID> <VALUE>700</VALUE> </INSTANCE> <INSTANCE> <AREAID>B</AREAID> <VARIABLEID>3</VARIABLEID> <VALUE>800</VALUE> </INSTANCE> <INSTANCE> <AREAID>D</AREAID> <VARIABLEID>3</VARIABLEID> <VALUE>900</VALUE> </INSTANCE> </DATA> </RESULTS> Thanks for your help Rupert For the latest data on the economy and society consult National Statistics at http://www.statistics.gov.uk ********************************************************************** Please Note: Incoming and outgoing email messages are routinely monitored for compliance with our policy on the use of electronic communications ********************************************************************** Legal Disclaimer : Any views expressed by the sender of this message are not necessarily those of the Office for National Statistics ********************************************************************** XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Missing nodes are ruining, David Carlisle | Thread | Re: [xsl] Missing nodes are ruining, David Carlisle |
Re: [xsl] Selecting specific portio, Mukul Gandhi | Date | Re: [xsl] Selecting specific portio, Paul Barclay |
Month |