Subject: Re: [xsl] What does position() really return From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 15 Mar 2001 17:56:48 +0000 |
<Personen>^ ^^^^^<Person>Jan</Person>^ ^^^^^<Person>Peter</Person>^ ^^^^^<Person>George</Person>^ ^^^^^<Person>Danny</Person>^ </Personen>
1. A text node (contains whitespace) 2. <Person>Jan</Person> 3. A text node (contains whitespace) 4. <Person>Peter</Person> etc.
Hope that helps, Wendell
Hi,
I'm trying to find out, what the position() function really returns. Browsing through the archive, some books and what's on the Internet and experimenting with it only increases my confusion. I have the following XML/XSL-code:
<?xml version="1.0" encoding="iso-8859-1"?> <Personen> <Person>Jan</Person> <Person>Peter</Person> <Person>George</Person> <Person>Danny</Person> </Personen>
<?xml version="1.0" encoding="iso-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="iso-8859-1" method="html" indent="yes"/>
<xsl:template match="/"> <html> <head> <title>Testfile</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template>
<xsl:template match="Personen"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="Person"> <p>Output: <xsl:value-of select="position()"/> <xsl:text>, </xsl:text> <xsl:value-of select="."/> </p> </xsl:template>
</xsl:stylesheet>
Running this with Saxon (Instant-Saxon, version 6.2.1 under Win98) produces the following result (result 1):
Output: 2, Jan Output: 4, Peter Output: 6, George Output: 8, Danny
Changing the "Personen" template to:
<xsl:template match="Personen"> <xsl:apply-templates> <xsl:sort select="."/> </xsl:apply-templates> </xsl:template>
generates (result 2):
Output: 6, Danny Output: 7, George Output: 8, Jan Output: 9, Peter
and once more changing "Personen" to:
<xsl:template match="Personen"> <xsl:apply-templates select="Person"> <xsl:sort select="."/> </xsl:apply-templates> </xsl:template>
results in (result 3):
Output: 1, Danny Output: 2, George Output: 3, Jan Output: 4, Peter
My confusion comes from the following:
- I have expected the position numbers *always* in the range between 1 and 4 - Why are the position values in result 1 multiples of 2 ? - Why are results 2 and 3 different (in terms of the position numbers) ?
Thanks in advance Jan
___________________________________________________________________ BISS GmbH, Chaukenweg 12, D-26388 Wilhelmshaven, Germany Phone: +49 4423 9289-0, Fax: +49 4423 9289-99 Dr. Jan Mazac, mailto: jwm@xxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] What does position() really r, Jan Mazac | Thread | RE: [xsl] What does position() real, Evan Lenz |
Re: [xsl] is it possible to access , David Carlisle | Date | RE: [xsl] saving forms, Chris Bayes |
Month |