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

Re: Storing XML doc refs in variables

Subject: Re: Storing XML doc refs in variables
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 30 Jan 2007 17:27:18 GMT
Re:  Storing XML doc refs in variables
> (since I don't want to load the document every time I need to access the
> data inside).

actually even if you do use document() or doc() more than once teh spec
guarantees that the result is stable, so in practice most systems cache
the result and don't actually fetch the document twice, as if they do
fetch it twice and it has changed in the interim, the system is
nob-conformant.


> The theory was that if styles.xml didn't exist, an empty document node
> would be created and assigned to the variable, meaning any future use
> would simple return an empty results set.

An xsl:variable with content but no as= attribute always geneartes a
document node, so your otherwise branch is not needed, but your when
branch is bad, as it will generate a _copy_ rather than a reference to,
your document. Also as you have used value-of rather than copy-of or
sequence, you are just getting the string value of the document.

try
 <xsl:variable name="styleXMLDoc" select="
if(doc-available('styles.xml')) then doc('styles.xml') else ()"/>


David

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.