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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format