You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "K. Ari Krupnikov" <ar...@cogsci.ed.ac.uk> on 2001/04/11 23:37:53 UTC

Re: Using DOMParser to produce a non-Xerces Document

Andy Clark wrote:
> 
> "K. Ari Krupnikov" wrote:
> > 1) add a constructor that takes a DOMImplementation argument and
> > overload init() and reset(). In this case,
> 
> I like this solution. Either a constructor or having a
> property for the DOMImplementation object works for me.
> Perhaps the second is better because people create their
> parsers from JAXP and have no way of passing arguments
> to the constructor. Unfortunately, though, JAXP doesn't
> have an extensive feature/property mechanism for DOM as
> it does for SAX -- so we're back to creating the parser
> object directly, anyway... <sigh/>
> 
> > I can patch DOMParser if there is interest in these solutions. It appers
> > that changes would be limited to org.apache.xerces.parsers.DOMParser
> 
> Patches for new features as well as bug fixes are always
> accepted. :)

Hi, I'm back again after a month of moving and getting connected.

I'm still trying to change DOMParser to work with my DBDOM database.

Here's a question about DTD and in particular, entity handling.

I need to intercept entity declarations in the DTD to build my own
DocumentType.Entities. Unlike SAXParser, DOMParser doesn't use
http://xml.org/sax/properties/declaration-handler. Xerces 1's DOMParser
has internalEntityDecl(int entityNameIndex, int entityValueIndex) which
cannot be used without stringpools (am I correct here? are stringpools
going away in Xerces 2?)
In Xerces 2, AbstractXMLDocumentParser has
internalEntityDecl(java.lang.String name, XMLString text) which looks
like org.xml.sax.ext.DeclHandler.internalEntityDecl(java.lang.String
name, java.lang.String value), except it's impossible to override with a
custom DeclHandler (or is it?)

So, short of using a SAX parser instead of a DOM one, is there a way to
override the default entity declaration handling in Xerces?

Ari.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Using DOMParser to produce a non-Xerces Document

Posted by "K. Ari Krupnikov" <ar...@cogsci.ed.ac.uk>.
Andy Clark wrote:
> 
> Xerces2 doesn't have a StringPool, so String objects are passed
> to the native interfaces. Both Xerces 1.x and Xerces2 have
> internal interfaces but at least we're trying to "standardize"
> the interfaces in Xerces2 (this is what we call XNI).
> 
> In both versions, you can directly extend the DOMParser class
> and override the appropriate method to get the information
> that you need. In Xerces 1.x, you'll have to turn the ints
> into String objects by calling the StringPool:
> 
>   String s = fStringPool.toString(i);
> 
> But in Xerces2, you'll just get the String object directly.

Is there a reason both versions of DOMParser, as well as
org.apache.xerces.xni.XMLDTDHandler don't use
org.xml.sax.ext.DeclHandler? The methods seem to have the same masks...

The alternative would be to go with a SAX parser, but then we'd have to
rewrite all Document.createXxx() calls, which looks like a waste.

Ari.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Using DOMParser to produce a non-Xerces Document

Posted by Andy Clark <an...@apache.org>.
Xerces2 doesn't have a StringPool, so String objects are passed
to the native interfaces. Both Xerces 1.x and Xerces2 have
internal interfaces but at least we're trying to "standardize"
the interfaces in Xerces2 (this is what we call XNI).

In both versions, you can directly extend the DOMParser class
and override the appropriate method to get the information
that you need. In Xerces 1.x, you'll have to turn the ints
into String objects by calling the StringPool:

  String s = fStringPool.toString(i);

But in Xerces2, you'll just get the String object directly.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org