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