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 2002/11/18 08:24:33 UTC

PSVI access through DOM in xerces-j

Hi guys,

I'm trying to use PSVI features in Xerces, and I need some help. I
understand Xerces 2.2.0 had a bug in the PSVI implementation that
caused NullPionterExceptions if you tried to run the samples. Sandy
was kind enough to point out that this bug had been fixed in 2.2.1,
and indeed xni.PSVIWriter now produces the expected output.

Now I'm trying to access the PSVI from
DOM. http://xml.apache.org/xerces2-j/faq-xs.html#faq-5 says:

   "Use http://apache.org/xml/properties/dom/document-class-name
   property to set org.apache.xerces.dom.PSVIDocumentImpl document
   interfaces implementation. In the resulting DOM tree, you may cast
   org.w3c.dom.Element to the org.apache.xerces.xni.psvi.ElementPSVI
   and org.w3c.dom.Attr to the
   org.apache.xerces.xni.psvi.AttributePSVI."

The code snippet that follows assumes that has been done. I assumed
that "use ... property to set ..." in the context of DOM means
inserting something like the following before the code in that sample:


    DocumentBuilderFactory factory = 
        DocumentBuilderFactory.newInstance();
    factory.setAttribute
       ("http://apache.org/xml/properties/dom/document-class-name",
        "org.apache.xerces.dom.PSVIDocumentImpl");

This throws no exceptions (and I know it does *something*, because if
I pass in a nonexistent class name, I get a
``java.lang.IllegalArgumentException: PAR003 Class,
"org.apache.xerces.dom.PSVIDocumentImpl.bogus", not found.'')

Unfortunately, builders produced by this factory still return
org.apache.xerces.dom.ElementImpl objects, not PSVIDocumentImpl.

There must be something very simple I'm missing.

It would be nice if the sample included a complete working example,
one that compiles and produces the expected results. It wouldn't have
to be very long. As far as I can tell, it would only add about a
half-dozen lines to the 12-line long example on
http://xml.apache.org/xerces2-j/faq-xs.html#faq-5

Ari.

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