Discussion:
[saxon] wiring an EntityResolver into saxon
pico
2007-01-10 19:43:14 UTC
Permalink
There is a lot of info in this forum about defining a custom EntityResolver
class to resolve schemas, DTDs, entities, etc.

I'd like to code a simple EntityResolver used when transforming an XHTML
document using XSLT. This is to prevent network trips during the transform.
I understand from other threads here that SAXParser is doing the remote
requests, not Saxon. But I don't understand how to tell saxon to tell
SAXParser to use a custom EntityResolver.

How can this be wired up?

I have Saxon B 8.8.04.

Thank you...
--
View this message in context: http://www.nabble.com/wiring-an-EntityResolver-into-saxon-tf2954703.html#a8264825
Sent from the saxon-help mailing list archive at Nabble.com.
pico
2007-01-10 19:44:49 UTC
Permalink
Another note; I would like to do this programatically, not via the command
line.
--
View this message in context: http://www.nabble.com/wiring-an-EntityResolver-into-saxon-tf2954703.html#a8264847
Sent from the saxon-help mailing list archive at Nabble.com.
Michael Kay
2007-01-11 23:51:24 UTC
Permalink
Basically, you construct a SAXSource object that contains an XMLReader
object, having first called setEntityResolver() on the XMLReader to make it
use your chosen EntityResolver. Then you pass the SAXSource as the input to
Saxon, e.g. on the transform(source, result) method.

If the transformation reads additional source documents using functions such
as doc() or document(), and you want your EntityResolver to be used on
these, then you have two options:

(a) write a URIResolver which processes the supplied URI and returns a
SAXSource constructed as above, or

(b) write your own implementation of XMLReader which is essentially just a
wrapper around the "real" XMLReader, but which always sets the
EntityResolver of the real XMLReader on initialization; then supply the name
of your private XMLReader class to the method
transformerFactory.setAttribute(FeatureKeys.SOURCE_PARSER_NAME,
"your.xmlreader.class").

Michael Kay
http://www.saxonica.com/
-----Original Message-----
Sent: 10 January 2007 19:43
Subject: [saxon] wiring an EntityResolver into saxon
There is a lot of info in this forum about defining a custom
EntityResolver class to resolve schemas, DTDs, entities, etc.
I'd like to code a simple EntityResolver used when
transforming an XHTML document using XSLT. This is to
prevent network trips during the transform.
I understand from other threads here that SAXParser is doing
the remote requests, not Saxon. But I don't understand how
to tell saxon to tell SAXParser to use a custom EntityResolver.
How can this be wired up?
I have Saxon B 8.8.04.
Thank you...
--
http://www.nabble.com/wiring-an-EntityResolver-into-saxon-tf29
54703.html#a8264825
Sent from the saxon-help mailing list archive at Nabble.com.
--------------------------------------------------------------
-----------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge
&CID=DEVDEV
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
Houghton,Andrew
2007-01-12 18:11:09 UTC
Permalink
In the course of writing an XSLT I noticed a discrepancy between the Saxon 8.8 documentation and the W3C XSL 2.0 documentation. The discrepancy is for the resolve-uri function.

Saxon docs give it as:

fn:resolve-uri(string $relative) ? string
fn:resolve-uri(string $relative, string $base) ? string

W3C docs give it as:

fn:resolve-uri($relative as xs:string?) as xs:anyURI?
fn:resolve-uri($relative as xs:string?, $base as xs:string) as xs:anyURI?

The difference is in the return value. xs:string for Saxon vs. xs:anyURI? for W3C. At least for what I was doing it wasn't an
issue since I wanted the URI as a string, I did wrap it with a
string() just to be safe, but the W3C version indicates that it
could return 0 or 1 xs:anyURI which might be an issue since the
Saxon version indicates it returns 1 xs:string.


Andy.
Michael Kay
2007-01-12 18:47:24 UTC
Permalink
Thanks. The W3C spec changed the return type at a fairly late stage; I
changed the Saxon code, but forgot to change the documentation.

Michael Kay
http://www.saxonica.com/
-----Original Message-----
Of Houghton,Andrew
Sent: 12 January 2007 18:11
To: Mailing list for SAXON XSLT queries
Subject: [saxon] Saxon documentation issue
In the course of writing an XSLT I noticed a discrepancy
between the Saxon 8.8 documentation and the W3C XSL 2.0
documentation. The discrepancy is for the resolve-uri function.
fn:resolve-uri(string $relative) ? string
fn:resolve-uri(string $relative, string $base) ? string
fn:resolve-uri($relative as xs:string?) as xs:anyURI?
fn:resolve-uri($relative as xs:string?, $base as xs:string)
as xs:anyURI?
The difference is in the return value. xs:string for Saxon
vs. xs:anyURI? for W3C. At least for what I was doing it
wasn't an issue since I wanted the URI as a string, I did
wrap it with a
string() just to be safe, but the W3C version indicates that
it could return 0 or 1 xs:anyURI which might be an issue
since the Saxon version indicates it returns 1 xs:string.
Andy.
--------------------------------------------------------------
-----------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge
&CID=DEVDEV
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
Loading...