OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SAX-ext Attribute + Entity Parsing


Asked this over on Sun's xml-interest list a while ago and haven't
gotten any reasonable answers. Thought I should try here as well...

I'm playing quite heavily with the SAX2 Extension APIs to dynamically
build document configuration information. I think I'm running into a
corner of the spec that isn't too well specified, but I'd like someone
to tell me if I've just got it all wrong or some workaround.

The reason for doing this is I'm writing a custom DOM builder that also
generates dual purpose objects that can be cast to either DOM or to
other classes. (For those interested, this is for the VRML3 X3D spec and
the Scene Authoring Interface).

Background: Building a custom parser implementation that can be loaded
with JAXP. I have my own DocumentBuildFactory implementation. To build
the DOM, I create a SAX parser and register everything with it -
ContentHandler, DTDHandler, DeclHandler and LexicalHandler. With these,
I build my DOM.

This is what I want to do:

To create a class that represents both the SAI field interface and the
DOM attribute I need to provide some mapping service between the name
the class type. To do this, I've registered myself as a SAX2
DeclHandler. In this, I have two methods:

    public void attributeDecl(String element,
                              String name,
                              String type,
                              String defValue,
                              String value)

    public void internalEntityDecl(String name, String value)

The former tells me that I have an attribute declaration. The latter
tells me about an internal entity declaration in the DTD.

In the DTD you have something like this:



   fieldName %SFFloat; #IMPLIED

What this gives me in code terms is a call to the internalEntityDecl
method with

name = %SFFloat, value = CDATA

and a call to attributeDecl with

element = "blah", name = fieldName, type = CDATA, defValue = null

From this, you can see that it is automatically expanding the internal
parameter entity to be a CDATA, rather than telling me the ENTITY type
(SFFloat). This is exceedingly frustrating. If I could get the type
parameter to give me the internal entity name then we'd be fine. I could
do internal lookups without having to go to some external source like a
properties file (the current implementation).

Does anyone know how I can set up the SAX parser or another way of
finding out the same information to tell me the entity name for that
type parameter rather than automagically expanding it for me? I'm using
the default parser with JAXP (Crimson). Under JAXP
1.1ea2 I have it set to not expandEntityRefs (haven't yet updated to

Justin Couch                                    Author, Java Hacker
http://www.vlc.com.au/~justin/               Java 3D FAQ Maintainer
http://www.j3d.org/              J3D.org The Java 3D Community Site
"Humanism is dead. Animals think, feel; so do machines now.
Neither man nor woman is the measure of all things. Every organism
processes data according to its domain, its environment; you, with
all your brains, would be useless in a mouse's universe..."
                                              - Greg Bear, Slant