Re: [xsl] Way to print the current context?

Subject: Re: [xsl] Way to print the current context?
From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 25 Apr 2025 18:26:41 -0000
Thanks all.B The fn:path() did the trick. I did also wrap that in a function
to remove the namespace. I used the replace() function, took me a minute to
realize the matching strings are regex values. I was getting an error about a
bad character. The namespace url had {} characters that needed to be
escaped...danSent from my Verizon, Samsung Galaxy smartphone
-------- Original message --------From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 4/25/25  6:00 AM  (GMT-08:00)
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Way to print the
current context? Hello,Just adding the obvious point that if you write
yourself a function or set of templates to write an XPath (as Dmitre has done)
you can also tune it to write better paths ('better' being relative to your
case).Templates make this pretty easy too and a niceB exercise for
beginner-intermediates.Regards, WendellOn Thu, Apr 24, 2025 at 9:11b/PM
Dimitre Novatchev dnovatchev@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:1. The standard XPath 3
function fn:path2. This XSLT transformation I wroteB years
ago:B https://stackoverflow.com/questions/4746299/generate-get-xpath-from-xml
-in-java/4747858#4747858Thanks,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">
B  B <xsl:param name="CONTEXT"/>
B  B <xsl:choose>
B  B  B  B  <xsl:when test="$CONTEXT/j:string[@key='description']">
B  B  B  B  B  B  <xsl:value-of
select="$CONTEXT/j:string[@key='description']"/>
B  B  B  B  </xsl:when>
B  B  B  B  <xsl:when
test="$CONTEXT/j:array[@key='item']/j:map[1]/j:map[@key='request']/j:string[@
key='description']">
B  B  B  B  B  B  <xsl:value-of
select="$CONTEXT/j:array[@key='item']/j:map[1]/j:map[@key='request']/j:string
[@key='description']"/>
B  B  B  B  </xsl:when>
B  B  B  B  <xsl:otherwise>
B  B  B  B  B  <xsl:message>ERROR: find_description_filepath() didn't resolve
"<xsl:value-of select="$CONTEXT/j:string[@key='name']"/>"</xsl:message>
B  B  B  B </xsl:otherwise>
B  B  </xsl:choose>
B  </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


B 



XSL-List info and archive

EasyUnsubscribe
(by email)



-- ...Wendell Piez... ...wendell -at- nist -dot- gov......wendellpiez.com...
...pellucidliterature.org... ...pausepress.org......github.com/wendellpiez...
...gitlab.coko.foundation/wendell...



XSL-List info and archive

EasyUnsubscribe
(by email)

Current Thread