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

Re: Can unparsed-text() consume an in-memory XML docu

Subject: Re: Can unparsed-text() consume an in-memory XML document? Can a string version of an XML document be converted into XML?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 13 Aug 2012 16:55:10 -0400
Re:  Can unparsed-text() consume an in-memory XML  docu
Dear Roger,

I'll assume you are using XSLT 2.0.

On 8/13/2012 4:15 PM, Costello, Roger L. wrote:
I have an XSLT program that uses unparsed-text() to read in an XML
document from a URL, the program then does some string manipulations
on the string version of the XML document, and then outputs the
result.

Cool.


Question about the input to unparsed-text():

Instead of it consuming the XML document from a URL, can it consume
an in-memory XML document (i.e., one that has already been parsed;
say, a variable whose value is an XML document)?

If an XML document has been parsed and is now available as an XDM instance (a full-fledged tree, not a string), then it isn't subject to string manipulations as such, so no.


You could, however, manipulate any strings you derived from it, including values of text nodes or elements in the tree or indeed of the tree itself. Depending on what your operations are and whether they expect or require XML markup, this could be fine for you.

You could also reserialize the tree into XML (as a string bound to a variable or parameter) using XSLT to serialize it (see Evan Lenz at http://lenzconsulting.com/xml-to-string/ for some ideas on this), and then process that. (This is not an approach I would ordinarily recommend, but you might have a special case.)

Question about reconstituting an XML document from the string version
of the XML document:

I can output the string version of the XML document to a file and
then read the file back in as an XML document. But I'd like to skip
that intermediate step and go straight from the string version of the
XML document to a full-fledged XML document. Is there a way in XSLT
to convert a string to XML?

In theory it is possible to implement an XML parser in XSLT, although it won't be a trivial task. (Yet at Balisage I just demonstrated an XSLT pipeline to process LMNL syntax, which is almost as hard. See the Proceedings.)


Saxon has an extension function, saxon:parse, that will also do this, if you have Saxon-PE or EE.

Cheers,
Wendell

--
======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.