Re: [xsl] Trying to Extract a node with matching attribute value with xsltproc

Subject: Re: [xsl] Trying to Extract a node with matching attribute value with xsltproc
From: "ohaya ohaya@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 24 Mar 2024 00:34:43 -0000
 I tried the XSL that Liam suggested, but it isn't finding anything :(....B 
Below is the xsltproc run with -v:
-bash-4.4$ xsltproc -v mulberry.xsl configfile.xml
creating dictionary for stylesheet
reusing dictionary from mulberry.xsl for stylesheet
xsltParseStylesheetProcess : found stylesheet
xsltPreprocessStylesheet: removing ignorable blank node
xsltCompilePattern : parsing '/'
xsltCompilePattern : parsed /, default priority 0.500000
added pattern : '/' priority 0.500000
parsed 1 templates
Resolving attribute sets references
Creating sub-dictionary from stylesheet for transformation
Registered 0 modules
reusing transformation dict for output
Registering global variables
Registering global variables from mulberry.xsl
xsltProcessOneNode: applying template '/' for /
xsltValueOf: select //Setting[@Name = 'TheOneIWant']
xsltValueOf: result ''
freeing transformation dictionary
freeing dictionary from stylesheet


Here's snippet of the XML file which should have matched:
B B B B B B B B B B B  <Setting Name="TheOneIWant" Type="htf:map">
B B B B B B B B B B B B B  <Setting Name="requiresignedassertion"
Type="xsd:boolean">false</Setting>
B B B B B B B B B B B B B  <Setting Name="succinctid"
Type="xsd:string">2KYi3gZ7THiZU0Hbft/mYgio0PE=</Setting>

..B B B B B B B B B  </Setting>..
Also, I think that I may not have been clear about what I want as the output
of running the XSLT...
If the XSLT was successful, I want the output to be the ENTIRE matching node,
including all the contents of the node, i.e.:
B B B B B B B B B B B  <Setting Name="TheOneIWant" Type="htf:map">
B B B B B B B B B B B B B  <Setting Name="requiresignedassertion"
Type="xsd:boolean">false</Setting>
B B B B B B B B B B B B B  <Setting Name="succinctid"
Type="xsd:string">2KYi3gZ7THiZU0Hbft/mYgio0PE=</Setting>

..B B B B B B B B B  </Setting>
That's why, in my original post, I thought I had to include use of the
identity transformation.

My apologies if I wasn't clear about that.
Thanks,Jim





    On Saturday, March 23, 2024 at 02:09:01 PM EDT, BR Chrisman
brchrisman@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

 Might needB to use <xsl:output method="text"/> as well.
On Fri, Mar 22, 2024 at 7:19b/PM Liam R. E. Quin liam@xxxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

On Sat, 2024-03-23 at 01:55 +0000, ohaya ohaya@xxxxxxxxx wrote:
[...]

I think what you want is simply XPath here.

But with XSLT you could use,

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

B  <xsl:template match="/">
B  B  <xsl:value-of select="//Setting[@Name = 'TheOneIWant']" />
B  </xsl:template>
</xsl:stylesheet>

The xsl:value-of "instruction" evalueates its argument and converts the
result to a string (actually a "text node").

The contents of the "select" attribute is an XPath expression.

liam


--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org



XSL-List info and archiveEasyUnsubscribe(by email)

Current Thread