|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to use saxon:node-set(document($f)) ?
Hi
I'm trying to write a stylesheet that produces some
nice error messages, instead of parser error messages,
when a configuration file cannot be loaded. Previously
I would load a configuration file (name specified on
the command line) with this:
<xsl:param name="CONFIG_FILE" select="'???'" />
<xsl:variable name="config" select="document($CONFIG_FILE)" />
This results in a fatal error if CONFIG_FILE is not
specified, with a (perhaps) unsightly error message.
Unfortunately if I put some "if"s around the document()
function, I get an RTF instead of a nodeset, but in
this case I'm prepared to use extension functions
like saxon:node-set().
So I tried this (fluff omitted) :
----- START XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:saxon="http://icl.com/saxon"
xmlns:file="java.io.File"
extension-element-prefixes="saxon"
exclude-result-prefixes="saxon">
<xsl:param name="CONFIG_FILE" select="'???'" />
<xsl:variable name="config">
<xsl:if test="$CONFIG_FILE != '???' and
file:exists(file:new($CONFIG_FILE))">
<xsl:value-of select="saxon:node-set(document($CONFIG_FILE))" />
</xsl:if>
</xsl:variable>
<xsl:template match="/">
<xsl:message terminate="yes">
<xsl:text>$config = </xsl:text>
<xsl:copy-of select="$config" />
</xsl:message>
</xsl:template>
</xsl:stylesheet>
----- END XSL
saxon:node-set(document($CONFIG_FILE)), and various simple
variations on that theme, appear to produce empty node-sets,
(yes it is called).
What am I doing wrong?
Thanks in advance.
--
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand
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
|

Cart








