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

position() problem : The code

Subject: position() problem : The code
From: François Parlant <fxp.xsl@xxxxxxxxxxx>
Date: Thu, 26 Jun 2003 15:46:38 +0200
xml position
Thank you for your concern.
My previous post (indexing and string replacement : position() problem in
document()) contained the full code and didn't get any answer (a rather
terrible sight of code i must admit) so I chose to make it [too] short in
(position() problem)

Here is a lite version of code.

**mydoc.xml***
<?xml version="1.0" encoding="iso-8859-1"?>
<doc>
This is a test
</doc>

**mygloss.xml**
<?xml version="1.0" ?>
<dic>
  <item>
        <mot>string</mot>
        <trans>chaine</trans></item>
  <item>
        <mot>tag</mot>
        <trans>balise</trans></item>
  <item>
        <mot>duplicate</mot>
        <trans>doublon</trans></item>
</dic>

**mystyle.xsl**
<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>


<xsl:template match="/">
  <xsl:call-template name="gloss"/>
</xsl:template>

<xsl:template name="gloss">
count=<xsl:value-of select="count(document('mongloss.xml')//mot)"/>
1) test1=<xsl:value-of select="document('mongloss.xml')//mot[1]"/>
2) test //mot[2]=<xsl:value-of select="document('mongloss.xml')//mot[2]"/>
3) test //mot['2']=<xsl:value-of
select="document('mongloss.xml')//mot['2']"/>
4) test //mot[position() = (number(2))]=<xsl:value-of
select="document('mongloss.xml')//mot[position() = (number(2))]"/>
5) test dic/item/mot[position()=2]=<xsl:value-of
select="document('mongloss.xml')/dic/item/mot[position()=2]"/>
6) test //mot['3']=<xsl:value-of
select="document('mongloss.xml')//mot['3']"/>
</xsl:template>

</xsl:stylesheet>

**OUTPUT**
(with Xalan-C_1_5-win32 and same with cocoon's xalan-j latest)

F:\eXist\webapp\cibapp\docs>xalan mondoc.xml monstyle6.xsl
xalan mondoc.xml monstyle6.xsl
<?xml version="1.0" encoding="iso-8859-1"?>

count=3
1) test1=string
2) test //mot[2]=
3) test //mot['2']=string
4) test //mot[position() = (number(2))]=
5) test dic/item/mot[position()=2]=
6) test //mot['3']=string


Thanks again for your help, this is only the tester complex part of a code
taken from the indexing article of Dave Pawson, and from the Jeni Tennison's
answer on string replacement.
And really I don't understand why there is no answer and why '2' gives
"string" for this.

François
Relativity? no! it's all about *context* ;-)

XSL FAQ : (http://www.dpawson.co.uk/xsl/sect2/sect21.html).


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.