Subject: Re: [xsl] Sorting and grouping unknown elements From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 25 Sep 2007 13:17:22 +0100 |
> Model and color is not processed (at least not the way I expect it) unfortunately that doesn't tell the rest of us what output you need. <xsl:for-each select="row/*[generate-id(.)=generate-id(key('n',name()))]"> selects the children of row if they are the first elements in the document with that name. that doesn't select much in your revised document as in most cases the first instance of each eleemnt is not under row. Two possible fixes, first chage that to <xsl:for-each select="*/*[generate-id(.)=generate-id(key('n',name()))]"> so you test all grandchilfren not just children of row, and same change (row to *) in <xsl:for-each select="../../*/*[generate-id(.)=generate-id(key('v',concat(name(current()),.)))]"> that gives $ saxon rs2.xml rs1.xsl <?xml version="1.0" encoding="utf-8"?> <select name="color"> <option>Blue</option> <option>Red</option> <option>White</option> </select> <select name="make"> <option>Toyota</option> </select> <select name="model"> <option>Corolla</option> <option>Supermarket</option> <option>Yaris</option> </select> <select name="name"> <option>Tesco</option> </select> or perhaps you do just want children of row in which case put them back to back to <xsl:for-each select="row/*[generate-id(.)=generate-id(key('n',name()))]"> <xsl:for-each select="../../row/*[generate-id(.)=generate-id(key('v',concat(name(current()),.)))]"> but make sure that only children of row are indexed, so that the test becomes, list the children of row that are the first such children with that name, so change <xsl:key name="n" match="*" use="name()"/> <xsl:key name="v" match="*" use="concat(name(),.)"/> to <xsl:key name="n" match="row/*" use="name()"/> <xsl:key name="v" match="row/*" use="concat(name(),.)"/> which makes $ saxon rs2.xml rs1.xsl <?xml version="1.0" encoding="utf-8"?> <select name="color"> <option>Blue</option> <option>Red</option> </select> <select name="make"> <option>Toyota</option> </select> <select name="model"> <option>Corolla</option> <option>Yaris</option> </select> Note no information from the cvr row) David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorting and grouping unkn, Claus Jessing | Thread | [xsl] Inserting an XSL variable as , Bhaskar _ |
Re: [xsl] apply-templates vs value-, Eric Bréchemier | Date | Re: [xsl] Processing Stylesheet wit, Joe Fawcett |
Month |