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

Re: Passing external URL for DTD reference

Subject: Re: Passing external URL for DTD reference
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Tue, 18 Nov 2003 20:41:20 +0100
external url
Pramodh Peddi wrote:
<!DOCTYPE EXAMPLE_DTD SYSTEM "xxx.dtd"> is there in the source xml. And
xxx.dtd is at http://myserver.com/xsl/xxx.dtd (the file name in the url can
be different - it can be named as yyy.dtd!). Can I know how to make the
transformer look at this url?
Probably yes.

I was passing in this URL to the StreamSource constructor - like
new StreamSource(new StringReader(stylesheetStream),this.dtdURL)

This sets the URL for the stylesheet. You don't want to do this, looking up relative hrefs to imported style sheets will be botched.

Can we achieve this in any other way? I was trying to use EntityResolver

This would be correct. You have to create a parser explicitely use it in a SAX source to take effect.

 public class MyResolver implements EntityResolver {
   public InputSource resolveEntity (String publicId, String systemId)
   {
     if (systemId.equals("xxx.dtd")) {
              // return a special input source
       MyReader reader = new MyReader();
       return new InputSource(http://myserver.com/xsl/xxx.dtd);
     } else {
              // use the default behaviour
       return null;
     }
   }
 }

Here we don't know that the file name would be "xxx.dtd". Can we say return
new InputSource(http://myserver.com/xsl/xxx.dtd); no matter what the xxx.dtd
in the xml source is?
Yes. However, the entity resolver will be invoked for every entity, and
some processors will it also invoke for the main input source. Therefore,
the default should be
  return new InputSource(systemId);
instead of returning null.


J.Pietschmann




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


Current Thread
  • RE: XPATH, (continued)
    • poppe chris - Mon, 17 Nov 2003 14:28:22 -0500 (EST)
    • cknell - Mon, 17 Nov 2003 14:44:23 -0500 (EST)
      • Pramodh Peddi - Mon, 17 Nov 2003 17:42:45 -0500 (EST)
        • J.Pietschmann - Tue, 18 Nov 2003 14:42:00 -0500 (EST) <=
    • poppe chris - Mon, 17 Nov 2003 17:41:38 -0500 (EST)

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.