Re: [xsl] how to "save" a context?

Subject: Re: [xsl] how to "save" a context?
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 14 Jan 2003 12:34:57 -0700 (MST)
S Woodside wrote:
> I want to "save" a context, e.g., when I'm in a specific context node, 
> I want to be able to serialize the context node such that I can pass 
> that serialization as a string or what not, to another XSLT that 
> processes the same original XML. Then I could simply 
> select="deserialize(myserializedString)" and jump to the same node. 
> Assuming the XML hasn't changed.
> 
> I read the spec and the FAQ... doesn't seem to be an easy way to do 
> this.
> 
> FWIW, the string has to go through an HTML forms client/server 
> roundtrip, it will be stored as a parameter in an HTML form, then when 
> they submit, the string will be used to access a subtree of the 
> original XML to expand that subtree and make new HTML forms for the 
> subtree.

You're right, there's no easy way.

Serializing a node tree into an XML string is something that most XSLT
processors can do via an extension function (though you may have to write it
yourself), and it's also possible to do "manually" with pure XSLT, as
demonstrated by Evan Lenz at http://www.xmlportfolio.com/xml-to-string/

Deserializing an XML string back into a node-set will definitely require an
extension function, because you need to run it through a real XML parser and
construct whatever DOM-like structure the vendor's implementation requires.

You can't reliably send serialized XML embedded in HTML form data unless you
use the multipart/form-data format (as is done for file uploads), and even
then, there is some risk. It is partly for this reason that things like SOAP
exist. Two years ago, I did a little writeup discussing the issues involved;
see http://skew.org/xml/misc/xml_vs_http/

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread