Re: [xsl] document('') returning null in certain environments?

Subject: Re: [xsl] document('') returning null in certain environments?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sun, 31 Oct 2010 00:18:50 +0100
There's no such thing as "null" in the XPath data model, but I suspect you mean that document('') is returning an empty node-set. The most likely explanation for that is that the base URI of the stylesheet is unknown. The W3C specs and RFCs don't like to admit that you can have a document whose base URI is unknown, but it can happen very easily in practice - for example the base URI of a DOM is always unknown, and the base URI of a Java StreamSource is unknown unless you explicitly set its SystemID property.

Michael Kay
Saxonica

On 31/10/2010 00:06, J Ferry wrote:
Let me start with the high level description of what I'm trying to
accomplish...

But first, I've got a limitation with the system I'm working with that
I can only use a single stylesheet for this particular document.

The document was originally developed as separate stylesheets, a
couple of which are the barcode stylesheets from RenderX.

I naively mashed them together into a single stylesheet and this seems
to work fine in my development environment (I was using OxygenXML now
using Ant) but it does not work when loaded into the target system (a
Java app running on SunOne/Tomcat). I'm not very good at debugging
stylesheets yet (someone needs to build a tool for that...) but I
think I've tracked the problem to the use of document(''). It appears
that the use of document('') in the target system (Tomcat/SunOne)
returns null, which is supposed to be used to select a value from a
character lookup table like this...

value =<xsl:value-of
select="document('')//my:char2value/entry[@char=$char and
@subset=$subset]/text()"/>

The lookup table looks like this...

<my:char2value>
     <entry char="&#x0020;" subset="A">0</entry>
     <entry char="&#x0020;" subset="B">0</entry>
     <entry char="00" subset="C">0</entry>
     <entry char="!" subset="A">1</entry>
     <entry char="!" subset="B">1</entry>
          :
          :
          :
</my:char2value>

Is there something I need to do to my runtime (different parser or
something) or is there a way to fix it in my stylesheet? I could put
together a more complete example if necessary but you'd still need the
runtime...

Regards,
Jeremy

Current Thread