xsl-list
[Top] [All Lists]

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

2012-09-30 08:56:40
[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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--