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

Passing external URL for DTD reference

Subject: Passing external URL for DTD reference
From: "Pramodh Peddi" <peddip@xxxxxxxxxxxxxxxx>
Date: Mon, 17 Nov 2003 15:40:37 -0500
external dtd reference
Hi,
I am using Java1.4 for Transformation.
My source xml file has a relative DTD reference (just the file name), but
the file is at a completely different http-accessible location. And I know
the url of that http-accessible location at the time of transforming. What I
am doing is similar to:

<!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?

I was passing in this URL to the StreamSource constructor - like
new StreamSource(new StringReader(stylesheetStream),this.dtdURL)
- though I know this is not proper to do. It seems to be resolving the url,
but seem to not really validating the xml stream against the dtd url (I
changed the dtd to make the xml source invalid, but it looks like its
passing through everything without validating it).

Can we achieve this in any other way? I was trying to use EntityResolver
(though I couldn't figure exactly how to do it, I kind of had the idea), but
I think we have to mention the systemID and publicID to the resolver, right?
At that point we don't know the dtd name mentioned in the xml source yet. I
guess we have to do something like:

 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?

Any help would be greatly appreciated!

Thanks,

pp.


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


Current Thread
  • RE: XPATH, (continued)
    • Michael Kay - Mon, 17 Nov 2003 13:58:27 -0500 (EST)
    • 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) <=
    • 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.