|
Subject: Re: [xsl] I mean self::* doesn't select attributes :( From: Francis Norton <francis@xxxxxxxxxxx> Date: Wed, 25 Apr 2001 10:54:36 +0100 |
"G. Ken Holman" wrote:
>
>
> This is an excerpt from pages 182/183 of my book:
>
Interesting - thank you.
Here's some code which had to solve a similar problem - it's intended to
generate a repeatable (same doc but different runs or different
processors) ID for any node in the XPath data model.
Replace the literal '+' characters with '/' characters and it should do
XPaths instead, though I haven't tested it!
Hope this helps!
Francis.
<!-- -->
<!-- repeatable-id maker -->
<xsl:template match="/" mode="schematron-get-full-path"/>
<xsl:template match="text()" mode="schematron-get-full-path">
<xsl:apply-templates select="parent::*"
mode="schematron-get-full-path"/>
<xsl:value-of select="concat('+text()[',
1+count(preceding-sibling::text()), ']')"/>
</xsl:template>
<xsl:template match="comment()" mode="schematron-get-full-path">
<xsl:apply-templates select="parent::*"
mode="schematron-get-full-path"/>
<xsl:value-of select="concat('+comment()[',
1+count(preceding-sibling::comment()), ']')"/>
</xsl:template>
<xsl:template match="processing-instruction()"
mode="schematron-get-full-path">
<xsl:apply-templates select="parent::*"
mode="schematron-get-full-path"/>
<xsl:value-of select="concat('+processing-instruction()[',
1+count(preceding-sibling::processing-instruction()), ']')"/>
</xsl:template>
<xsl:template match="@*" mode="schematron-get-full-path">
<xsl:apply-templates select="parent::*"
mode="schematron-get-full-path"/>
<xsl:value-of select="concat('+@', name())"/>
</xsl:template>
<xsl:template match="*" mode="schematron-get-full-path" priority="-0.5">
<xsl:apply-templates select="parent::*"
mode="schematron-get-full-path"/>
<xsl:text>+</xsl:text>
<xsl:choose>
<xsl:when test="count(. | ../namespace::*) =
count(../namespace::*)">
<xsl:value-of
select="concat('+namespace::[',1+count(namespace::*),']')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="concat('+',name(),'[',1+count(preceding-sibling::*[name()=name(current())]),']')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] I mean self::* doesn't se, Michael Kay | Thread | Re: [xsl] I mean self::* doesn't se, David Carlisle |
| RE: [xsl] Table Building Problem, Meltem Kogelbauer | Date | [xsl] Genetic algorithm in XSL: Sne, Juan Julian Merelo G |
| Month |