Finding the "real" base URI of a file

View: New views
2 Messages — Rating Filter:   Alert me  

Finding the "real" base URI of a file

by Norman Walsh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I load a file from a URI that involves one or more redirections, can
I find out from Saxon what it's "real" URI is? I think this is the URI that
Saxon has to use if it expands entity references, so I think Saxon has to
know it, but (somewhat to my surprise, though I'm jet lagged and haven't
thought carefully about it) it's not the base URI of the document XdmNode.

                                        Be seeing you,
                                          norm

--
Norman Walsh <ndw@...> | It is seldom that any liberty is lost
http://nwalsh.com/            | all at once.--David Hume


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

attachment0 (191 bytes) Download Attachment

Re: Finding the "real" base URI of a file

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> If I load a file from a URI that involves one or more
> redirections, can I find out from Saxon what it's "real" URI
> is? I think this is the URI that Saxon has to use if it
> expands entity references, so I think Saxon has to know it,
> but (somewhat to my surprise, though I'm jet lagged and
> haven't thought carefully about it) it's not the base URI of
> the document XdmNode.

I suspect this answer is incomplete, but perhaps it will help anyway:

Generally, if a document is built using a SAX parser, then the SystemId
property of the DocumentInfo is the SystemId reported by the SAX parser in
the SAX Locator object. How this relates to the "real URI" is anyone's
guess. If the document comes from any other kind of Source, then the
SystemId property typically comes from the SystemId property of the JAXP
Source object from which the DocumentInfo was loaded. (I would need to check
that for a StAX Source.)

The SystemId property of element nodes is also taken from the SAX Locator:
it will be the same as the SystemId property of the containing document,
unless the document is parsed from multiple external entities.

The BaseURI property of an element or document node is derived from the
SystemId property, modified by any xml:base attributes.

Saxon of course doesn't expand entity references. It leaves that to the XML
parser, or indeed to the user-supplied EntityResolver.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help