|
Subject: RE: [xsl] can one include/import XML data into stylesheets? From: "Michael Kay" <mhk@xxxxxxxxx> Date: Mon, 2 Feb 2004 14:45:06 -0000 |
document('') gives you an XML representation of the current stylesheet
module, in its state before any processing of xsl:include. So this won't
work.
But you could put a global variable in the included stylesheet module of
the form
<xsl:variable name="x" select="document('')/*/gem:data/..." />
and then in the main module you could refer to this variable.
Michael Kay
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Lars Huttar
> Sent: 02 February 2004 14:20
> To: XSL-List (E-mail)
> Subject: [xsl] can one include/import XML data into stylesheets?
>
>
> Hello all,
>
> I have a stylesheet that uses
> <xsl:value-of
> select="document('../resources/gem-data.xml')/*/gem:data/..."
> /> to access some data it needs. My question is, instead of
> using document('path...'), can I use
> <xsl:include href="../resources/gem-data.xsl" />
> (where gem-data.xsl is a stylesheet that has the data of
> gem-data.xml at the top level) and then later
> <xsl:value-of select="document('')/*/gem:data/..." />
> ?
>
> In other words, will the <xsl:include> pull the data from
> the included file into the document tree of the includer
> stylesheet so that document('') can access it?
>
> The spec says,
> "The resource located by the href attribute value is parsed
> as an XML document, and the children of the xsl:stylesheet
> element in this document replace the xsl:include element in
> the including document."
>
> Trying it in Cocoon with Xalan, it doesn't seem to work, i.e.
> the value-of instruction is getting nothing. The same thing
> happens in Saxon. Is there a way to do this that I'm not
> getting, or is it just not possible?
>
> Here is my test stylesheet (includer):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:gem="http://www.sil.org/namespace/gem">
> <xsl:include href="../resources/gem-data.xsl" />
> <xsl:output method="html" indent="yes"/>
>
> <xsl:template match="/">
> <xsl:value-of select="count(document('')/*/gem:data)" />
> </xsl:template>
>
> </xsl:stylesheet>
>
> Included stylesheet (../resources/gem-data.xsl):
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <gem:data xmlns:gem="http://www.sil.org/namespace/gem">
> ...
> </gem:data>
> </xsl:stylesheet>
>
>
> The reason I wanted to try xsl:include/document('') instead
> of document('path') is that Cocoon frowns on the use of
> document('path'); it messes up caching. Not that it matters
> much; the data is basically static anyway.
>
> Thanks,
> Lars
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] can one include/import XML da, Lars Huttar | Thread | RE: [xsl] can one include/import XM, Lars Huttar |
| [xsl] Problem with Variables, Gerald Fingerlos | Date | Re: [xsl] Problem with Variables, David Carlisle |
| Month |