[xsl] Way to print the current context?
oXygen provides a nice utility where you place your cuursor on an
element and it will give you an xpath to that element.
/fn:map/fn:array[1]/fn:map[2]/fn:array[1]/fn:map[1]/fn:map[2]/fn:string[2]
It doesn't give you any of the attribute values that are on the various
elements for selecting, but it does give you a good underztanding of
where you are on the tree.
I have this function where I pass the current context to look up a value
based upon which element I'm in.
<xsl:function name="ping:find_description_filepath">
<xsl:param name="CONTEXT"/>
<xsl:choose>
<xsl:when test="$CONTEXT/j:string[@key='description']">
<xsl:value-of
select="$CONTEXT/j:string[@key='description']"/>
</xsl:when>
<xsl:when
test="$CONTEXT/j:array[@key='item']/j:map[1]/j:map[@key='request']/j:string[@key='description']">
<xsl:value-of
select="$CONTEXT/j:array[@key='item']/j:map[1]/j:map[@key='request']/j:string[@key='description']"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>ERROR: find_description_filepath() didn't resolve
"<xsl:value-of select="$CONTEXT/j:string[@key='name']"/>"</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
In the error message I have giveen another value to help locate the
issue, but I'd rather get something like the oXygen output as something
is going wrong. I've tested my xpath in the Xpath editor and it does
match content properly for some of the thing's I've tested, but it isn't
working when I run it from the stylesheet.
..dan