[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

doc() function failing to load DTD

Michael Ludwig mlu at as-guides.com
Wed Apr 15 11:48:44 PDT 2009


  doc() function failing to load DTD
George Feinberg schrieb:
> Michael,
>
> Your issue is somewhat product-specific.  In this case you are using
> Berkeley DB XML and it's dbxml shell program for testing.

Hi George :-) Yes, exactly, dbxml shell for testing.

> The problem is not the URI for the file but the file's reference to
> the DTD.  BDB XML uses Xerces-C for parsing/validation and
> by default Xerces-C will look in the current directory for DTDs
> referenced by a relative pathname (e.g. "Sender.dtd").  If you
> change that to an absolute pathname or file: URI your query
> will succeed.

Yes, that works.

> In BDB XML you have another option if you write it into your
> program (vs using the dbxml shell).  You can implement XmlResolver
> and resolve entities such as DTDs yourself.

That works fine, too. I took a look at the C++ sample program contained
in the Berkeley DB XML distribution and implemented something similar to
set a base URI for external entities, which I'm appending in case anyone
is looking for it.

Regards,

Michael Ludwig

public final class TestResolver extends XmlResolver {
   private String dir;

   public void setDirectory(String dir) {
     if (dir.endsWith("/"))
       this.dir = dir;
     else
       this.dir = dir + "/";
   }

   public XmlInputStream resolveEntity(
       XmlTransaction txn, XmlManager mgr,
       String systemId, String publicId) throws XmlException
   {
     String path = dir + systemId;
     System.err.format("RESOLVER: %s -> %s%n", systemId, path);
     return mgr.createLocalFileInputStream(path);
   }
}

Usage:

   TestResolver resolver = new TestResolver();
   resolver.setDirectory( "C:/MILU/dev");
   xmlManager.registerResolver(resolver);



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-2007 All Rights Reserved.