Subject: RE: [xsl] Three questions on sorting.. From: "Chris Bayes" <Chris@xxxxxxxxxxx> Date: Wed, 20 Jun 2001 11:16:04 +0100 |
Tim, sort can have no child elements just change <xsl:sort select="model"> to <xsl:sort select="model"/> remove </xsl:sort> and take 2 asprins Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml >-----Original Message----- >From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx >[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Tim >Sent: 20 June 2001 10:58 >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >Subject: [xsl] Three questions on sorting.. > > >Hi, > >XML/XSL is below. These problems are causing a very red forehead >(since I keep banging it on the table in confusion!) > >1. Why does the <xsl:sort/> cause a "tr is not allowed in this position >in the stylesheet" error? If I take the sorting tags out, it is quite >happy. > >2. Can the <xsl:sort/> use a variable directly? e.g. <xsl:sort >select="$orderBy"><xsl:sort> I'll try it myself when I can get the >answer to question 1! > >3. I would like to sort by manufacturer name but it is in an external >file. Is there a way of ordering by the <name/> of the manufacture? I >can order by the manufacturer ID but not the external name. Xpointer? > >Thanks for your time, >Tim. >_______________________ >Cars.xml ><cars> > <car ID="car1"> > <model> > 88 Type 2a SWB > </model> > <price> > 1200 > </price> > <manufacturer> > manufacturer2 > </manufacturer> > </car> > <car ID="car2"> > <model> > Mundaino > </model> > <price> > 4500 > </price> > <manufacturer> > manufacturer1 > </manufacturer> > </car> ></cars> > >_______________________ >manufacturers.xml ><manufacturers> > <manufacturer ID="manufacturer1"> > <name> > Ford > </name> > <notes> > Ford Motor Company > </notes> > </manufacturer> > <manufacturer ID="manufacturer2"> > <name> > Land Rover > </name> > <notes> > Good solid, slow cars. Not good for motor way driving but will >pull the side off a house if necessary. > </notes> > </manufacturer> ></manufacturers> > >_______________________ >cars.xsl ><?xml version="1.0" encoding="UTF-8"?> ><xsl:stylesheet version="1.0" >xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >xmlns:fo="http://www.w3.org/1999/XSL/Format"> ><xsl:output method="html"/> ><xsl:variable name="col" select="document >('http://localhost/xml/manufacturers.xml')"/> > <xsl:template match="/"> > <xsl:apply-templates select="/cars"/> > </xsl:template> > > <xsl:template match="cars"> > <table> > <tr> > <td> > <a> > <xsl:attribute >name="href"><xsl:value-of >select="$targetURL"/>manufacturer</xsl:attribute> > Manufacturer > </a> > </td> > <td> > <a> > <xsl:attribute >name="href"><xsl:value-of select="$targetURL"/>model</xsl:attribute> > Model > </a> > </td> > <td> > <a> > <xsl:attribute >name="href"><xsl:value-of select="$targetURL"/>price</xsl:attribute> > Price > </a> > </td> > </tr> > <xsl:for-each select="car"> > <xsl:sort select="model"> > <tr> > <td> > > <xsl:variable name="cat_id"> <xsl:value-of select="normalize- >space(manufacturer)"/></xsl:variable> > <xsl:value-of >select="$col/manufacturers/manufacturer[@ID=$cat_id]/name/text()"/> > </td> > <td> > > <xsl:value-of select="normalize-space(model)"/> > </td> > <td> > > <xsl:value-of select="normalize-space(price)"/> > </td> > </tr> > </xsl:sort> > </xsl:for-each> > </table> > </xsl:template> > ></xsl:stylesheet> > > > > 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 -> |
---|---|---|
[xsl] Three questions on sorting.., Tim | Thread | Re: [xsl] Three questions on sortin, David Carlisle |
[xsl] Three questions on sorting.., Tim | Date | Re: [xsl] Three questions on sortin, David Carlisle |
Month |