This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: node-set from a string?
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 2 Jul 2002 17:49:32 -0600 (MDT)
- Subject: Re: [xsl] node-set from a string?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Charles Knell wrote:
> I need to find a way to pass a well-formed XML string into an
> XSLT transformation
Long story short: you can't, at least not with pure, unextended XSLT.
Some XSLT processors do allow passing in a node-set as a parameter, but not
from the command line. You'll have to check the docs for your processor to see
whether it is even possible. Even if it is possible, you have to pass in
whatever the XSLT processor's implementation of a node-set is, which will
require constructing such an object yourself, by parsing the XML string. The
string itself is something you can derive a node-set from; it's not a
node-set, itself.
Better way: assign the XML string a URI (saving it to the local filesystem
would be one way), and use the document() function to access its root node. If
the string is in memory, use a custom URI resolver (again, check your
processor's docs) to access it. For example, you would make the custom
resolver return the XML string when it is asked for URI 'urn:my-xml-string';
then you need only pass in 'urn:my-xml-string' as parameter foo, and access it
via document($foo).
Other option: write an extension function or element that will take a string
argument, feed it to a parser, and return/produce a node-set. Again, check
your docs, as the implementation will vary from vendor to vendor.
> I think I need to use the "oracle:node-set()" function
The node-set() extension function won't help you convert a string to a
node-set.
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list