|
Subject: [xsl] Sort problem From: "Paolo Noya" <paolo.noya@xxxxxxxxxxx> Date: Fri, 10 Sep 2004 17:19:49 +0200 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Classic many-to-many sort, David Carlisle | Thread | Re: [xsl] Sort problem, David Carlisle |
| Re: [xsl] Word 2003 schema and XSL, Emmanouil Batsis | Date | Re: [xsl] getting date and time usi, Paul Coletti |
| Month |