xsl-list
[Top] [All Lists]

Re: [xsl] Storing XML doc refs in variables

2007-01-30 10:27:38

(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

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>