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

Re: JAXP: SAXResult.setSystemId()

Subject: Re: JAXP: SAXResult.setSystemId()
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 31 Dec 2007 10:15:29 +0000
Re:  JAXP: SAXResult.setSystemId()
On 31/12/2007, Florent Georges <lists@xxxxxxxxxxxx> wrote:
>   Hi
>
>   First, I think JAXP questions are on topic here (as long
> as they are about its XSLT part).  Please correct me if I am
> wrong.
>
>   I thought that the SAXResult.setSystemId(String) method
> set the System ID of the SAX events thrown by the transform.
> But the following code displays the System ID of the
> stylesheet:
>
>     public static void main(String[] args)
>             throws TransformerException
>     {
>         // stylesheet and input sources
>         Source style_src = ...;
>         Source input = ...;
>
>         // the stylesheet
>         SAXTransformerFactory factory = new TransformerFactoryImpl();
>         Templates style = factory.newTemplates(style_src);
>
>         // the SAX handler
>         ContentHandler handler = new DefaultHandler() {
>             public void setDocumentLocator(Locator loc) {
>                 System.err.println(loc.getSystemId());
>             }
>         };
>
>         // the result, encapsulating the handler
>         SAXResult result = new SAXResult();
>         result.setHandler(handler);
>         result.setSystemId("http://sample.com/system-id");
>
>         // the transform
>         style.newTransformer().transform(input, result);
>     }
>
>   Tested with Saxon 9.
>
>   Did I mix up something?

Maybe...

Normally with a SAXTransformerFactory you set the result using

handler.setResult(...)

and start the transform by call parse on the XMLReader eg:

xmlReader.setContentHander(...)
xmlReader.parse(...)

...but you've used the "standard" way for a normal TransformerFactory
- I'm not sure the handler gets the events that way.

cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.