users@jaxb.java.net

ENTITY resolving and (separate) problems with Xerces?

From: Andrew Ferguson <Andrew.Ferguson_at_arm.com>
Date: Wed, 1 Sep 2004 18:58:17 +0100

hi,

 two questions have got me stumped at the moment..

-----
(1) ENTITY resolution

I've been asked to investigate the possiblity of using something like

        <!ENTITY name "SQL EXPRESSION">

to allow people to have SQL expressions evaluated while the xml is being
parsed and substituted into appropriate places (which are then executed
by the application)

this seems a little exotic to me but I've not been able to find anything
actually wrong with it (we don't expect anyone else to be able to use
the files in this form)

does it seem a reasonable thing to try to do?
I guess its as simple as adding an EntityResolver to an XmlReader and
then having jaxb unmarshalling happen via a SaxSource?

-----
(2) Problems with Xerces (?)

When using Xerces as a validating or non-validating parser I'm getting
an error message saying

        "Unexpected end of element {}:VAR"

where I can verify that

        a) the xsd passed to xjc declares VAR to be empty:
                <xsd:complexType name="VAR">
                        <xsd:attribute name="n" type="xsd:string"
use="required"/>
                        <xsd:attribute name="v" type="xsd:string"
use="required"/>
                </xsd:complexType>
        b) the dtd that the xml instance document declares via a DOCTYPE
also declares VAR to be empty:
                <!ELEMENT VAR EMPTY>
                <!ATTLIST VAR
                  n CDATA #REQUIRED
                  v CDATA #REQUIRED
>
        c) the XML instance document correctly uses VAR:
                <VARIETY>
                      <VAR n="c" v="2"/>
              </VARIETY>

I've made sure that the file being parsed really is the one that is
being complained about, and have recompiled my application from scratch
- this feels like I've missed something trivial but I've now run out of
things to check..

The XmlReader and SaxParser are instances of classes:
        com.sun.org.apache.xerces.internal.parsers.SAXParser
        com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

(running under a build of jre1.5)

I've tried
        a) not having the unmarshalling perform any validation
        b) not having the SAX parser perform any validation
and it doesn't seem to have any effect - if the document is parsed via
sax then the unmarshaller.unmarshal(...) call always reports a FATAL
error to the validation handler (which in then hrows a runtime
exception)

are there any known problems with using xerces via jaxb in this way?

any help appreciated :)
thanks,
Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net