Re: [xsl] getting xml file info

Subject: Re: [xsl] getting xml file info
From: Stephane Bortzmeyer <bortzmeyer@xxxxxx>
Date: Wed, 30 Apr 2003 12:48:32 +0200
On Tue, Apr 29, 2003 at 11:16:09AM -0700,
 Nathan Shaw <n8_shaw@xxxxxxxxx> wrote 
 a message of 34 lines which said:

> A while back, I wrote an XSLT that uses the saxon
> extension function system-id() to get the file path
> info of the xml file that I am parsing. 

What does system-id() return when the XML input is not a file? For
instance, the standard input on an Unix machine? Or a DOM tree parsed
a long time ago? I believe that the difficulty to reply to this
question is one of the reasons why system-id() is not standard.

> how else could I get this information? If they do not
> exist natively in the parsers, am I looking at having
> to either write my own extension function to do this
> or pass the info in from the XML file (which kind of
> defeats the purpose)?

The way I do it, which is standard (it does not rely on extensions):

In the XSL stylesheet:

  <xsl:param name="current_dir">(UNSPECIFIED)</xsl:param>
  <xsl:param name="current_host">(UNSPECIFIED)</xsl:param>
...
  <xsl:text>Generated on </xsl:text><xsl:value-of select="$current_host"/>

In the Makefile which calls the XSL processor:

        xsltproc -o $@ \
                --stringparam current_dir "`pwd`" \
                --stringparam current_host "`hostname -f`" \
                ${STYLESHEET} $<

If you use something else than xsltproc, you just have to change the
Makefile, not the stylesheet.



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


Current Thread