Subject: Re: Re: RE: [xsl] sequence numbering. From: "william locksman" <vsd18@xxxxxxxxxxxxxx> Date: 2 Apr 2002 16:04:52 -0000 |
Hi William,
> about the name space,
> The Declartion i am using is
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xalan="http://xml.apache.org/xslt"
> xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
> extension-element-prefixes="redirect"
> version="1.0">
>
> and i am using XALAN processor
OK, then you should be able to use xalan:nodeset() extension function
(see http://xml.apache.org/xalan-j/extensionslib.html#nodeset).
[It seems likely that the next version of Xalan will support EXSLT
functions. See the recent mail from Don Leslie
(http://aspn.activestate.com/ASPN/Mail/Message/exslt/1083089). With
that version, you'll be able to use the namespace
http://exslt.org/common, and the function exsl:node-set(), which would
make your stylesheet portable across a range of processors, including
Saxon, libxslt, 4XSLT and jd.xslt.]
Cheers,
Jeni
--- Jeni Tennison http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Hi the solution Michael Suggested seems to fit my purpose, But Since i am a newbie to XSL , I do not know how to form a temporary tree that contains sorted sequence.
Michael's explaination made me pretty much clear of what has to be done. But i do not know how it has to be done.
If any one can please suggest me how to go about doing it or give me a link to any reference document, It should be of much help to me
Thanks
William
On Tue, 26 Mar 2002 Michael Kay wrote :<xsl:number> gives you the position of the element in the source tree, not
in the sorted sequence. To get the number in the sorted sequence, do a
two-phase transformation: create a temporary tree that contains the sorted
products, then process this (using xx:node-set()) to add the numbers. To get
the number for a product among all the products of the same colour, use
<xsl:number count="product[color=$this_color]"/>
Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of william
> locksman
> Sent: 26 March 2002 16:34
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] sequence numbering
>
>
> <products>
> <product id = "1">
> <name>product1</name>
> <weight>56</weight>
> <color>blue</color>
> </product>
> <product id = "2">
> <name>product2</name>
> <weight>56</weight>
> <color>red</color>
> </product>
> <product id = "3">
> <name>product3</name>
> <weight>56</weight>
> <color>red</color>
> </product>
> <product id = "4">
> <name>product4</name>
> <weight>56</weight>
> <color>blue</color>
> </product>
> <product id = "5">
> <name>product5</name>
> <weight>56</weight>
> <color>blue</color>
> </product>
> </products>
>
> for the above xml for all the color elements in the xml file,
> get the products.. in other words group the products based on
> there colors
> and then assosiate the products with a serial num . This serial id
> is
> in the series of 1,2,3... 1 for the first product that is of a
> perticular color, 2 for the next product and so on..
>
> xsl i wrote..
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <xsl:for-each select="//product/color">
> <xsl:sort select="." data-type="text" order="descending"/>
> <xsl:number format="1" count="product"/> ...<xsl:value-of
> select="."/>..<xsl:value-of select="../name"/>
> <br></br>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> with above xsl , I am getting an out put
>
> 3 ...red..product3
>
> 2 ...red..product2
>
> 5 ...blue..product5
>
> 4 ...blue..product4
>
> 1 ...blue..product1
>
> which is quite understandable... But i wanted the output which
> should look like
>
> 1 ...red..product3
>
> 2 ...red..product2
>
> 1 ...blue..product5
>
> 2 ...blue..product4
>
> 3 ...blue..product1
>
> that is for each of the colors of the same type i need the
> sequence number to start from 1
>
> any suggestions and ideas will be most appreciated and helpful
> many thanks in advance
> bill..
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
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 -> |
---|---|---|
Re: [xsl] repeat and replace loop (, Jeni Tennison | Thread | Re: Re: RE: [xsl] sequence numberin, Joerg Heinicke |
Re: [xsl] Keep two FO rows together, David B. Bitton | Date | RE: [xsl] Which parser is used when, Jakub . Valenta |
Month |