Re: [xsl] Global variable reads in the input XML document using the document() function ... sometimes it works, sometimes it doesn't

Subject: Re: [xsl] Global variable reads in the input XML document using the document() function ... sometimes it works, sometimes it doesn't
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 27 Oct 2012 07:04:13 -0700
> I have an XSLT program which has a global variable that uses the document()
> function to read in the XML document that the program was invoked with:

.  .  .  .  .  .  .  .   .  .  .   .  .   .  .  .    .   .  .
>     <xsl:variable name="file" select="document(.)"/>

Seems I don't understand: Isn't the required variable definition simply:

     <xsl:variable name="file" select="/"/>

In case the transformation is processing multiple XML documents, the
current document can be obtained (in XPath 2.0 / XSLT 2.0)using

    root()


Cheers,

Dimitre

On Sat, Oct 27, 2012 at 6:11 AM, Costello, Roger L. <costello@xxxxxxxxx> wrote:
> Hi Folks,
>
> I have an XSLT program which has a global variable that uses the document() function to read in the XML document that the program was invoked with:
>
> ------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                            version="2.0">
>
>     <xsl:variable name="file" select="document(.)"/>
>
>     <xsl:template match="/">
>         ...
>     </xsl:template>
>
> </xsl:stylesheet>
> ------------------------------------------------------
>
> On some input XML documents that XSLT program works, and on others I get a horrific error message such as this:
>
> FODC0002: Exception thrown by URIResolver: Invalid relative URI
> {\n\t\t\t\tThis%20is%20an%20ann...}: Illegal character in path at index 0:
>
> It appears that the problem is with this statement:
>
>     <xsl:variable name="file" select="document(.)"/>
>
> Sometimes the document() function finds the input XML file and sometimes it doesn't.
>
> Why?
>
> I solved the problem by passing into the XSLT program the filename of the input XML file and then invoking document() with that filename. But I'd like to understand why the other approach doesn't work.
>
> /Roger
>



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

Current Thread