[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sort problem

Subject: Sort problem
From: "Paolo Noya" <paolo.noya@xxxxxxxxxxx>
Date: Fri, 10 Sep 2004 17:19:49 +0200
paolo noya
Hi,
I've a problem during sort node with xalan-j version 2.4.1(bundle with jdk 1.4.2_05). 
I have an XML like this:
=======================
<?xml version="1.0"?>
<Peoples>
    <Person>
        <Name>Johnson</Name>
        <Level>foo</Level>
    </Person>
    <Person>
        <Name>Smith</Name>
        <Level>baz</Level>
    </Person>
    <Person>
        <Name>White</Name>
        <Level>foo</Level>
    </Person>
    <Person>
        <Name>Brown</Name>
    </Person>
    <Person>
        <Name>Black</Name>
        <Level>bar</Level>
    </Person>
</Peoples>
=======================
and I want sort by level and then by name giving a rule for mapping level with an arbitrary number.
I wrote an xml like this:
=======================
<?xml version="1.0"?>
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:this="http://localhost/" exclude-result-prefixes="this"
>
 
<this:Levels>
    <Level pos="0"/><!--dummy level-->
    <Level pos="1">foo</Level>
    <Level pos="2">bar</Level>
    <Level pos="3">baz</Level>
</this:Levels>
 
<xsl:variable name="levels" select="document('')/xsl:stylesheet/this:Levels"/>
 
<xsl:template match="/Peoples">
    <xsl:apply-templates select="Person">
        <xsl:sort data-type="number" select="number($levels/Level[.=current()/Level]/@pos)"/>
        <xsl:sort select="Name"/>
    </xsl:apply-templates>
</xsl:template>
 
<xsl:template match="Person">
    <xsl:value-of select="Name"/><br/>
</xsl:template>
 
</xsl:stylesheet>
=======================
 
during transfom, the element  <xsl:sort data-type="number" select="number($levels/Level[.=current()/Level]/@pos)"/> produce an excepiton javax.xml.transform.TransformerException: java.lang.NullPointerException

but if i print the <xsl:value-of select="number($levels/Level[.=current()/Level]/@pos)"/> in "Person" template I got the correct value.
If apply the same transform directly with my IE6.0 (so using msxml transformer) i obtain the correct result.
 
What's wrong?
It is my error suppose that the current() function inside sort element refer to selected node in apply-templates?
 
regards,
Paolo

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.