GeeCON Prague 2014*
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
Author

xslt sorting year problem

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2452
    
    8

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:
<projects><system><name><description><impl_year></system></projects>
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

K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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
Bartender

Joined: Sep 13, 2007
Posts: 2452
    
    8

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