|
Subject: [xsl] RE : [xsl] xsl:sort blocks of element with an attribute value From: "Stephane Dion" <stephane@xxxxxxxxxxx> Date: Tue, 18 Oct 2005 13:52:23 -0400 |
Hi
Even if I removed the namespace from my source, my output is not
sorted.
The output document is missing the ProductOption element! Why?
<?xml version="1.0" encoding="UTF-8"?><GetProductOptionsResponse>
<Header/>
<DetailedProduct>
<ProductOptionGroup>
<NetPrice>W</NetPrice>
<NetPrice>M</NetPrice>
<TravelerPrice>
<PriceSummary/>
</TravelerPrice>
</ProductOptionGroup>
</DetailedProduct>
</GetProductOptionsResponse>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>
<xsl:template
match="/GetProductOptionsResponse/DetailedProduct/ProductOptionGroup/Product
Option">
<xsl:apply-templates>
<xsl:sort data-type="number" select="NetPrice/@NetAmount"
order="ascending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I would like the original source document (with all attributes) with
the NetPrice elements sorted.
Please help!
Stephane
-----Message d'origine-----
De : Michael Kay [mailto:mike@xxxxxxxxxxxx]
Envoyi : October 17, 2005 13:30
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Objet : RE: [xsl] xsl:sort blocks of element with an attribute value
Your source document has a default namespace, so the names in your path
expressions and match patterns in the stylesheet need to be prefixed.
Google for "XSLT FAQ default namespace"
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Stephane Dion [mailto:stephane@xxxxxxxxxxx]
> Sent: 17 October 2005 17:47
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] xsl:sort blocks of element with an attribute value
>
>
> It's not working.
>
> In my case, I'm not sure if I should use xsl:for-each instead of
> apply-template. I read the documentation but it's not clear
> for me. What do
> you think?
>
> Thanks
> Stephan
>
> -----Message d'origine-----
> De : Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Envoyi : October 17, 2005 10:19
> @ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Objet : RE: [xsl] RE : RE: [xsl] xsl:sort blocks of element with an
> attribute value
>
> I think you want
>
> <xsl:sort select="NetPrice/@netAmount" data-type="number"/>
>
> - though this doesn't handle multiple currencies!
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Stephane Dion [mailto:stephane@xxxxxxxxxxx]
> > Sent: 17 October 2005 15:05
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: [xsl] RE : RE: [xsl] xsl:sort blocks of element with
> > an attribute value
> >
> > Hi
> >
> > As requested, this is my stylesheet.
> >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="2.0">
> > <xsl:output method="xml"/>
> > <xsl:template
> > match="/GetProductOptionsResponse/DetailedProduct/ProductOptio
> > nGroup/Product
> > Option">
> > <xsl:apply-templates>
> > <xsl:sort data-type="number" select="@NetPrice"
> > order="ascending"/>
> > </xsl:apply-templates>
> > </xsl:template>
> >
> > <xsl:template match="*">
> > <xsl:copy>
> > <xsl:apply-templates/>
> > </xsl:copy>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > Thanks for your help
> > Stephan
> >
> > Hi
> >
> > Could someone help me with this.
> >
> > I would like to sort each NetPrice block by the
> > attribute value
> > netAmount (ascending) of each block.
> >
> > Here is my XML:
> >
> > <GetProductOptionsResponse
> xmlns="http://www.accovia/TRIP2004A/01";>
> > <Header language="en" version="5.1.0"/>
> > <DetailedProduct availabilityStatus="available">
> > <ProductOptionGroup description="OPTION GROUP 1">
>
> > <ProductOption description="option A">
> > <NetPrice currency="EUR" netAmount="2.27"
> > priceReferenceID="HTLAVO13XAAX" quantity="1"/>
> > <NetPrice currency="EUR" netAmount="-45.09"
> > priceReferenceID="HTLAVO13XAAX" quantity="1"/>
> > <TravelerPrice age="10" travelerId="003">
> > <PriceSummary baseAmount="0.00"/>
> > </TravelerPrice>
> > </ProductOption>
> > <ProductOption description="option B">
> > <NetPrice currency="EUR" netAmount="2.27"
> > priceReferenceID="HTLAVO13XAAX" quantity="1"/>
> > <NetPrice currency="EUR" netAmount="-45.09"
> > priceReferenceID="HTLAVO13XAAX" quantity="1"/>
> > <TravelerPrice age="10" travelerId="003">
> > <PriceSummary baseAmount="0.00"/>
> > </TravelerPrice>
> > </ProductOption>
> > </ProductOptionGroup>
> > <ProductOptionGroup description="OPTION GROUP 2">
>
> > <ProductOption description="option Z">
> > <NetPrice currency="EUR" netAmount="5.55"
> > priceReferenceID="BHTLAVO13XAAX" quantity="1"/>
> > <NetPrice currency="EUR" netAmount="-145.09"
> > priceReferenceID="BHTLAVO13XAAX" quantity="1"/>
> > <TravelerPrice age="99" travelerId="001">
> > <PriceSummary baseAmount="1.00"/>
> > </TravelerPrice>
> > </ProductOption>
> > </ProductOptionGroup>
> > </DetailedProduct>
> > </GetProductOptionsResponse>
> >
> > I have tried many many ways without success.
> >
> > Thanks in advance for your help
> > Stephan
> >
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] RE : [xsl] xsl:sort blocks of, Stephane Dion | Thread | Re: [xsl] RE : [xsl] xsl:sort block, Wendell Piez |
| [xsl] Select single node having hig, Nick Fitzsimons | Date | Re: [xsl] Re: xsl-list Digest 18 Oc, Jon Gorman |
| Month |