XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
zeinah KSubject: XSL does not sort
Author: zeinah K
Date: 20 Jul 2006 02:01 AM
Hi friends,

Could you help me with this please. i have tried all possible things
but in vain, what i want is my original xml but with employee sorted by
the attribute "x". my xsl refuses to do that.What have i missed?

Here is my xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:aco="http://www.org/TRIP2004A/01"
version="1.0">
<xsl:output method="xml"/>

<xsl:template match="/aco:details/aco:employees">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates>
<xsl:sort data-type="number" select="@x" order="ascending"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>

<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

And here is my xml

<details>
<employees>
<test>fgdsfg</test>
<employee hireDate="04/23/1999" x="3">
<last>Hill3</last>
<first>Phil</first>
<salary>100000</salary>
</employee>
<test>fgdsfg</test>
<test1>fgdsfgfgfdg</test1>
<employee hireDate="09/01/1998" x="1">
<last>Herbert1</last>
<first>Johnny</first>
<salary>95000</salary>
</employee>
<employee hireDate="08/20/2000" x="2">
<last>Hill2</last>
<first>Graham</first>
<salary>89000</salary>
</employee>
</employees>
<employees>
<employee hireDate="04/23/1999" x="6">
<last>Hill6</last>
<first>Phil6</first>
<salary>100000</salary>
</employee>
<employee hireDate="09/01/1998" x="1">
<last>Herbert1</last>
<first>Johnn1</first>
<salary>95000</salary>
</employee>
<employee hireDate="08/20/2000" x="5">
<last>Hill5</last>
<first>Graham5</first>
<salary>89000</salary>
</employee>
</employees>
</details>

Thanks Zeinah

Postnext
Ivan PedruzziSubject: XSL does not sort
Author: Ivan Pedruzzi
Date: 20 Jul 2006 02:39 AM
Hi Zeinah,

You have two groups called "employees" of elements "employee".
Do you need to sort the elements inside each group or something else?

Could you post the result you are looking for?


Ivan Pedruzzi
Stylus Studio Team

Postnext
zeinah KSubject: XSL does not sort
Author: zeinah K
Date: 20 Jul 2006 02:44 AM
here is what i want

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<details>
<employees>
<test>fgdsfg</test>
<employee hireDate="09/01/1998" x="1">
<last>Herbert1</last>
<first>Johnny</first>
<salary>95000</salary>
</employee>
<test>fgdsfg</test>
<test1>fgdsfgfgfdg</test1>
<employee hireDate="08/20/2000" x="2">
<last>Hill2</last>
<first>Graham</first>
<salary>89000</salary>
</employee>
<employee hireDate="04/23/1999" x="3">
<last>Hill3</last>
<first>Phil</first>
<salary>100000</salary>
</employee>

</employees>

<employees>
<employee hireDate="09/01/1998" x="1">
<last>Herbert1</last>
<first>Johnn1</first>
<salary>95000</salary>
</employee>

<employee hireDate="08/20/2000" x="5">
<last>Hill5</last>
<first>Graham5</first>
<salary>89000</salary>
</employee>

<employee hireDate="04/23/1999" x="6">
<last>Hill6</last>
<first>Phil6</first>
<salary>100000</salary>
</employee>

</employees>
</details>

Postnext
Ivan PedruzziSubject: XSL does not sort
Author: Ivan Pedruzzi
Date: 20 Jul 2006 03:00 AM
Your XSLT works just fine.

There is only one discrepancy:

You have a template that matches /aco:details/aco:employees where prefix "aco" is bound to the namespace "http://www.org/TRIP2004A/01" but your input document is not using that namespace.

You either change the input document root to be the following
<details xmlns="http://www.org/TRIP2004A/01">

or change the match attribute to be
<xsl:template match="/details/employees">

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
zeinah KSubject: XSL does not sort
Author: zeinah K
Date: 20 Jul 2006 03:06 AM
Thanks thanks, i have added the xmlns="http://www.org/TRIP2004A/01">
now it shows properly.
:-)

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.