I think, IIUC, you had asked for a way to get the full path to the current context node in xpath format. below is a template I was given on the xsl list. calling dyn:evaluate or whatever on this will give you back the nodeset or result tree fragment or whatever.
simon
> So how do I best handle the POST/GET parameters? I want to be able to<xsl:template name="thepath">
> grab the params from the POST/GET whatever and feed the unique ID back
> into the RNG-HTMLForms XSLT to generate the appropriate new section.
Use a naming scheme with which you can uniquely identify which input param
belongs to which Schema entry. I use the following, which might be
inappropriate for full RNG, I don't know:
top-level tag FOO's elements are called FOO[0], FOO[1], ... plus a hidden
FOO[] holding the count of them (empty fields are usually not sent back, so
they would get lost otherwise). An element bAr below the first FOO is called
FOO[0]bAr[0], FOO[0]bAr[1] and so on, again with a hidden FOO[0]bAr[] for the
count. This preserves order and tree structure, only it can't express things
like <foo/><bar/><foo/>, nor does it do <foo>Hello <bar>World</bar>!</foo>.
If you need that, be sure to tell me which solution you found :-)
<xsl:variable name="theResult">
<xsl:variable name="theNode" select="."/>
<xsl:for-each select="$theNode | $theNode/ancestor-or-self::node()[..]">
<xsl:element name="slash">/ </xsl:element>
<xsl:choose>
<xsl:when test="self::*">
<xsl:element name="nodeName">
<xsl:value-of select="name()"/>
<xsl:variable name="thisPosition"
select="count(preceding-sibling::*[name(current()) = name()])"/>
<xsl:variable name="numFollowing"
select="count(following-sibling::*[name(current()) = name()])"/>
<xsl:if test="$thisPosition + $numFollowing > 0">
<xsl:value-of select="concat('[', $thisPosition + 1, ']')"/>
</xsl:if>
</xsl:element>
</xsl:when>
<xsl:otherwise> <!-- This node is not an element -->
<xsl:choose>
<xsl:when test="count(. | ../@*) = count(../@*)">
<!-- Attribute -->
<xsl:element name="nodeName">
<xsl:value-of select="concat('@',name())"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::text()">
<!-- Text -->
<xsl:element name="nodeName">
<xsl:value-of select="'text()'"/>
<xsl:variable name="thisPosition"
select="count(preceding-sibling::text())"/>
<xsl:variable name="numFollowing"
select="count(following-sibling::text())"/>
<xsl:if test="$thisPosition + $numFollowing > 0">
<xsl:value-of select="concat('[', $thisPosition + 1, ']')"/>
</xsl:if>
</xsl:element>
</xsl:when>
<xsl:when test="self::processing-instruction()">
<!-- Processing Instruction -->
<xsl:element name="nodeName">
<xsl:value-of select="'processing-instruction()'"/>
<xsl:variable name="thisPosition"
select="count(preceding-sibling::processing-instruction())"/>
<xsl:variable name="numFollowing"
select="count(following-sibling::processing-instruction())"/>
<xsl:if test="$thisPosition + $numFollowing > 0">
<xsl:value-of select="concat('[', $thisPosition + 1, ']')"/>
</xsl:if>
</xsl:element>
</xsl:when>
<xsl:when test="self::comment()">
<!-- Comment -->
<xsl:element name="nodeName">
<xsl:value-of select="'comment()'"/>
<xsl:variable name="thisPosition"
select="count(preceding-sibling::comment())"/>
<xsl:variable name="numFollowing"
select="count(following-sibling::comment())"/>
<xsl:if test="$thisPosition + $numFollowing > 0">
<xsl:value-of select="concat('[', $thisPosition + 1, ']')"/>
</xsl:if>
</xsl:element>
</xsl:when>
<xsl:when test="count(. | ../namespace::*) = count(../namespace::*)">
<!-- Namespace: -->
<xsl:variable name="apos">'</xsl:variable>
<xsl:element name="nodeName">
<xsl:value-of select="concat('namespace::*',
'[local-name() = ', $apos, local-name(), $apos, ']')"/>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:value-of select="$theResult"/>
</xsl:template>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
