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

can one include/import XML data into stylesheets?

Subject: can one include/import XML data into stylesheets?
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Mon, 2 Feb 2004 08:20:15 -0600
xsl include document
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

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"
  <xsl:include href="../resources/gem-data.xsl" />
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
  	<xsl:value-of select="count(document('')/*/gem:data)" />


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

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.


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

Current Thread


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.
First Name
Last Name
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.