File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes xslt sorting year problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xslt sorting year problem" Watch "xslt sorting year problem" New topic

xslt sorting year problem

K. Tsang

Joined: Sep 13, 2007
Posts: 2676

Hello all, I try to sort the year field in my xml file using <xsl:sort> by following link but I'm not getting the desired result. Here is my sorting code:

And my xml file consists of tags:
And my schema elements
<xsd:element name="name" type="xsd:string" />
<xsd:element name="description" type="xsd:string" />
<xsd:element name="impl_year" type="xsd:year" />

Then when I load the xml file, 1) I don't see anything and 2) if I have the templates but use <xsl:for-each> tag, then my data isn't sorted. What's going on? Thanks

Paul Clapham

Joined: Oct 14, 2005
Posts: 19133

First of all, the <xsl:apply-templates> causes XSLT to process the children of the "system" elements. Those are "name" elements according to your description of the XML. Do you have a template that does that? (I don't see one but maybe you didn't post it.) If not, do you know what XSLT's default processing rule is for an element?

Second, the <xsl:sort> element specifies the sequence for processing those "name" elements. According to your description of the XML, they don't have "impl_year" elements as their children so the sorting won't do anything.
K. Tsang

Joined: Sep 13, 2007
Posts: 2676

Interesting Paul. I will have a look and get back if I have more problems.
subject: xslt sorting year problem