Subject: [xsl] Storing XML doc refs in variables From: "Rick Livesey" <rick.livesey@xxxxxxxxxxxx> Date: Tue, 30 Jan 2007 12:06:00 -0500 |
Hi all, I'm a bit new to XSL so please excuse me if I'm asking a daft question: I need to be able to load multiple XML documents (using the document() function) and store the resultant document node within a variable, (since I don't want to load the document every time I need to access the data inside). This is easy enough using the following statement: <xsl:variable name="styleXMLDoc" select="document('styles.xml')" /> However, on some occasions styles.xml may not exist, and causes an exception in the XSL engine, so to get around this I attempted to use the XSL2 doc-available() function: <xsl:variable name="styleXMLDoc" > <xsl:choose > <xsl:when test="doc-available('styles.xml')"> <xsl:value-of select="document('styles.xml')"/> </xsl:when> <xsl:otherwise> <xsl:document /> </xsl:otherwise> </xsl:choose> </xsl:variable> 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. However this code doesn't work (the variable is assigned, but I think it's being assigned as type text) and I can't figure out whether it's because you can't have a non-determinant variable that contains document nodes (unlikely) or whether the dummy document node created in the 'otherwise' branch is not syntactically correct, therefore the engine doesn't know what type to assign the variable. Any help / examples would be greatly received, Rick
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Naming conventions for xs, Mukul Gandhi | Thread | Re: [xsl] Storing XML doc refs in v, David Carlisle |
Re: [xsl] EXSLT support for firefox, Florent Georges | Date | Re: [xsl] Dynamic, configurable tra, Yves Forkl |
Month |