[xslt] Order of element within exsl:node-set()



Hello, All!

I'm use exsl:node-set() element for collecting authors to a
variable, but order of elements in exsl:node-set() looks strange
for me...

I'm run
$ xsltproc --xinclude test.xsl test.xml
on attached files and get output:

Sorted authors output from the source document
Ievlev Levin Levin Ostanin Ostanin 
Collect sorted authors to variable...
Unsorted authors output from the variable?
Ostanin Ostanin Ievlev Levin Levin

exsl:node-set() does not keep original order of elements ?

PS Sorry for bad English

-- 
Regards, Vyt
mailto:  vyt@vzljot.ru
JID:     vyt@vzljot.ru
<?xml version="1.0"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
                  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>

<section>

  <sectioninfo>
    <revhistory>
      <revision>
	<revnumber>0.1</revnumber>
	<date lang="en">21 May 2002</date>
	<revremark>
	  some
	</revremark>
      </revision>
    </revhistory>
    <author lang="en">
      <include xmlns="http://www.w3.org/2001/XInclude";
	href="http://docs.altlinux.ru/persons/persons.xml#xpointer(id('vyt')/info[@lang='en']/*)"/>
    </author>
  </sectioninfo>
  
  <title>Common title</title>
  <section>
    <sectioninfo>
      <author lang="en">
	<include xmlns="http://www.w3.org/2001/XInclude";
	  href="http://docs.altlinux.ru/persons/persons.xml#xpointer(id('ldv')/info[@lang='en']/*)"/>
    </author>
      <author lang="en">
	<include xmlns="http://www.w3.org/2001/XInclude";
	  href="http://docs.altlinux.ru/persons/persons.xml#xpointer(id('vyt')/info[@lang='en']/*)"/>
    </author>
    </sectioninfo>
    <title>title1</title>
    <para>text1</para>
  </section>

  <section>
    <sectioninfo>
      <author lang="en">
	<include xmlns="http://www.w3.org/2001/XInclude";
	  href="http://docs.altlinux.ru/persons/persons.xml#xpointer(id('inger')/info[@lang='en']/*)"/>
    </author>
      <author lang="en">
	<include xmlns="http://www.w3.org/2001/XInclude";
	  href="http://docs.altlinux.ru/persons/persons.xml#xpointer(id('ldv')/info[@lang='en']/*)"/>
    </author>
    </sectioninfo>
    <title>title2</title>
    <para>text2</para>
  </section>
</section>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:exsl="http://exslt.org/common"; 
  exclude-result-prefixes="exsl">

  <xsl:output method="text"/>

  <xsl:template match="/">

  <xsl:text>&#10;Sorted authors output from the source document&#10;</xsl:text>
  <xsl:for-each select="//author">
    <xsl:sort select="surname"/>
    <xsl:value-of select="surname"/>
    <xsl:text> </xsl:text>
  </xsl:for-each>

  <xsl:text>&#10;Collect sorted authors to variable...</xsl:text>
  <xsl:variable name="authors">
    <xsl:for-each select="//author">
      <xsl:sort select="surname"/>
      <xsl:copy-of select="."/>
    </xsl:for-each>
  </xsl:variable>

  <xsl:text>&#10;Unsorted authors output from the variable?&#10;</xsl:text>
  <xsl:for-each select="exsl:node-set($authors)/author">
    <xsl:value-of select="surname"/>
    <xsl:text> </xsl:text>
  </xsl:for-each>

</xsl:template>

</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]