[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [xslt v1.0] How to parse the string as node-set?

Subject: Re: [xslt v1.0] How to parse the string as node-set?
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Sun, 30 Sep 2012 09:56:28 -0400
Re: [xslt v1.0] How to parse the string as node-set?
[Hmmm. I sent this 2012-09-29 10:14 (before I had received Ken
Holman's "2 steps or vendor extension" reply), but it doesn't seem to
have made it to the list. Since the technique demonstrated for doing
2 XSLT steps from a shell commandline is potentially useful to OP and
others, I'm trying again.]

I'd do this in two passes. Presuming you have "xmlstarlet" installed
and in your shell path as `xmlstarlet`[1], the following (all on one
line, of course) should do the trick.

$ xmlstarlet select --text
    -N T=http://xmlexchangeservice.com/
    --template
    --match "//T:InputXML"
    --value-of "."
    input.xml
    |
    xmlstarlet select
      -N tns=urn:schemas:x12:org:V00200806:CoverageRequest
      --xml-decl
      --template
      --match "//tns:Organization"
      --copy-of "."

(I've used long options to make it clearer to readers who aren't
familiar with xmlstarlet's switches.)

If you don't have xmlstarlet, you can obviously do the same thing by
actually writing the two stylesheets: one that extracts <InputXML>
into a file as text, and another that reads in that file as XML.

Notes
-----
[1] Some package managers install xmlstarlet as the `xml` command.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.