|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using a reference in a sort
I am trying to sort data based on an externally referred to value. My main XML file looks like this: <task> <person id="p001"> ... </person> </task> p001 refers to a person in another file structured like this: <people> <person id="p001" last="Heines" first="Jesse"> ... </person> </people> I can get at that person's last name by defining a variable to point to the file: <xsl:variable name="filePeople" select="string('people.xml')" /> and then using that variable inside a template using an xsl:value-of: <xsl:value-of select="document($filePeople)/people/person[@id=$strPersonID]/@last" /> (where $strPersonID is the ID extracted from the main XML file). What I can't seem to be able to do is sort using this field. <xsl:apply-templates select="tasks/task"> <xsl:sort select="document($filePeople)/people/person[@id=$strPersonID]/@last" order="descending" /> </xsl:apply-templates> The problem is that one must use variables due to the context node switching in this long XPath statement, but XSL won't let me use xsl:variable inside an xsl:apply-templates statement. The variable must be defined inside the xsl:apply-templates tag so that it changes with each recursion. I tried using xsl:for-each, which does allow xsl:variable inside it, but only *after* xsl:sort, so that doesn't work either. I would appreciate any suggestions anyone can make to address these issues. Thank you, Jesse Heines, heines@xxxxxxxxxx UMass Lowell Computer Science XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






