[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Trying to Extract a node with matching attribute
Are there any namespace declarations in your XML file? A common reason for XPath expressions not selecting anything is that you ignored the namespaces. Michael Kay Saxonica > On 24 Mar 2024, at 00:35, ohaya ohaya@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > I tried the XSL that Liam suggested, but it isn't finding anything :(.... 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: > > <Setting Name="TheOneIWant" Type="htf:map"> > <Setting Name="requiresignedassertion" Type="xsd:boolean">false</Setting> > <Setting Name="succinctid" Type="xsd:string">2KYi3gZ7THiZU0Hbft/mYgio0PE=</Setting> > > . > . > </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.: > > <Setting Name="TheOneIWant" Type="htf:map"> > <Setting Name="requiresignedassertion" Type="xsd:boolean">false</Setting> > <Setting Name="succinctid" Type="xsd:string">2KYi3gZ7THiZU0Hbft/mYgio0PE=</Setting> > > . > . > </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 need to use <xsl:output method="text"/> as well. > > On Fri, Mar 22, 2024 at 7:19b/PM Liam R. E. Quin liam@xxxxxxxxxxxxxxxx <mailto:liam@xxxxxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx <mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote: > On Sat, 2024-03-23 at 01:55 +0000, ohaya ohaya@xxxxxxxxx <mailto: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"> > > <xsl:template match="/"> > <xsl:value-of select="//Setting[@Name = 'TheOneIWant']" /> > </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, 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: http://www.fromoldbooks.org <http://www.fromoldbooks.org/> > > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3475705> (by email <>) > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by email <>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|