Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xslt sorting year problem

 
K. Tsang
Bartender
Posts: 3457
14
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Posts: 21137
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3457
14
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting Paul. I will have a look and get back if I have more problems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic