Subject: Re: [xsl] Way to print the current context? From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 25 Apr 2025 01:11:03 -0000 |
1. The standard XPath 3 function fn:path 2. This XSLT transformation I wrote years ago: https://stackoverflow.com/questions/4746299/generate-get-xpath-from-xml-in-ja va/4747858#4747858 Thanks, Dimitre. On Thu, Apr 24, 2025 at 3:40b/PM dvint@xxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Way to print the current , Peter Flynn peter@xx | Thread | Re: [xsl] Way to print the current , Wendell Piez wapiez@ |
Re: [xsl] Way to print the current , Peter Flynn peter@xx | Date | Re: [xsl] Way to print the current , Wendell Piez wapiez@ |
Month |