[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XALAN does not handle document('') as expected to

Subject: Re: XALAN does not handle document('') as expected to carry out an in-stylesheetlook-up
From: David_N_Bertoni@xxxxxxxxx
Date: Thu, 1 Nov 2001 15:12:40 -0500
xalan document function uri
Hi Mark,

> Hi
>
> In order to sort items by date where we are provided with the date in dd
> mmm yyyy format (e.g. 03 Jan 2001) I wanted to convert the MMM value to a
> number which can be sorted.
>
> I used the approach where I embedded a look-up within the stylesheet and
> then used the document('') function to look up the month in the table to
> get the number to sort by (see code segment below).
>
> This works fine when I run XALAN from the command line.  However my
> application applies the template after reading the XSL transform from a
> database and then applying it to a document.  When this occurs XALAN
> appears to be attempting to obtain a document from the file server when
my
> understanding was that the document('') function means that the lookup
> table can be held within the stylesheet itself.
>

I think you're assuming that when Xalan processes the stylesheet for use as
a stylesheet, that it also processes the stylesheet as a potential source
document.  This is not the case -- In a call to the document function,
Xalan parses the stylesheet document separately, as though it were parsing
any other source document.

> Does anyone know if this is a known feature or have I missed something
> here?  Your help is appreciated.
>
> Thanks
>
> Mark Clare

Working as designed.  I suspect that most processors work this way, since
stylesheets are processed with the goal of building an efficient run-time
mechanism for performing the transformation described by the stylesheet.
Also, there are different rules for interpreting stylesheet xml files and
source documents.  From the recommendation:

   "When the first argument to the document function is not a node-set, the
   first argument is converted to a string as if by a call to the string
   function. This string is treated as a URI reference; the resource
   identified by the URI is retrieved. The data resulting from the
   retrieval action is parsed as an XML document and a tree is constructed
   in accordance with the data model (see [3 Data Model])."

and

   "Note that a zero-length URI reference is a reference to the document
   relative to which the URI reference is being resolved; thus document("")
   refers to the root node of the stylesheet; the tree representation of
   the stylesheet is exactly the same as if the XML document containing the
   stylesheet was the initial source document."

Of course, a processor _could_ detect references to the stylesheet by
looking for any calls to the document() function, but it would be
impossible to detect all cases, so I don't see how this would work.

You might think about using an EntityResolver to solve this problem.  I'd
recommend you post a question on the Xalan mailing list for more
information.

Dave


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.