[xquery-talk] doc() function failing to load DTD

George Feinberg gmf at maine.rr.com
Thu Apr 9 15:58:13 PDT 2009


Michael,

Your issue is somewhat product-specific.  In this case you are using
Berkeley DB XML and it's dbxml shell program 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.

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.

Regards,
George

On Apr 9, 2009, at 11:57 AM, Michael Ludwig wrote:

> The XQuery implementation of an XML database fails to resolve the URI
> of the DTD specified in the SYSTEM identifier.
>
> dbxml> query { doc('file:/home/milu/xpg/xml/Sender.xml') }
> 1 objects returned for eager expression
> ' doc('file:/home/milu/xpg/xml/Sender.xml') '
>
> dbxml> print
> <?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
> <!DOCTYPE Senderliste SYSTEM "Sender.dtd">
> <Senderliste Name="KOMPLETT">
> 	&Sender;
> 	<SenderJeSeite> 3 </SenderJeSeite>
> 	&Gruppen;
> </Senderliste>
>
> DTD loading attempted, but failing:
>
> dbxml> query { doc('file:/home/milu/xpg/xml/Sender.xml')/* }
> stdin:55: query failed, Error:
> XML Indexer: Fatal Parse error in document at line, 2, char 43.
> Parser message: An exception occurred!
> Type:RuntimeException, Message:Could not open DTD file 'Sender.dtd'
>
> Changing the URI to file:///home/milu/xpg/xml/Sender.xml doesn't help.
>
> The DTD is in the same directory as the document, and parsing the
> document from other contexts works fine.
>
> So I think the database engine should be able to retrieve it using the
> base URI of the document. Is this assumption correct?
>
> Michael Ludwig
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk



More information about the talk mailing list