You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Swanson, Brion" <Br...@westgroup.com> on 2001/08/10 20:12:08 UTC

creating an null DOCTYPE in Xerces2

I'm having some difficulty creating a null DOCTYPE with the new Xerces2
beta.  Perhaps this is a bug, or perhaps I'm simply going about it wrong.
I'm using the JAXP interfaces to get the DOMImplementation.  Then I attempt
to call 'createDocumentType(...)' as follows:

===============

	doctype = dom.createDocumentType ("", "", "");

	recordDoc = dom.createDocument ("", localName, doctype);

===============

I've also tried using the keyword 'null' in place of the empty string, but
to no avail.  Each attempt is met with a runtime exception
"org.w3c.dom.DOMException: DOM002 Illegal character."

The reason I'm trying to create a null doctype is because for the time
being, I have no desire to validate my documents, but wish to create (via
the DOMImplementation) a new document with a dynamically-determined document
element name.  I seem to recall the 'createDocument(...)' method blowing up
if it receives a null doctype element - but I haven't tried that since
Xerces 1.1 or so.

This particular code was changed from:

===============

	doctype = new DocumentTypeImpl (null, null, null, "");

===============

in order to utilize the JAXP interface and remove or dependence on Xerces
(though there is no plan to use another parser in the short term).

This second snippet worked in Xerces 1.2.3.  I'm wondering if I did
something horrendous in my 'translation' to JAXP, or if there is indeed
something wrong with Xerces2.

Thank you for you help regarding this matter.

Brion Swanson

--------------
Brion Swanson
Software Engineer
West Group - Public Records
Brion.Swanson@westgroup.com
(716)546-5530 ext. 3659

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


Re: creating an null DOCTYPE in Xerces2

Posted by Edwin Goei <ed...@sun.com>.
"Swanson, Brion" wrote:
> 
> I'm having some difficulty creating a null DOCTYPE with the new Xerces2
> beta.  Perhaps this is a bug, or perhaps I'm simply going about it wrong.
> I'm using the JAXP interfaces to get the DOMImplementation.  Then I attempt
> to call 'createDocumentType(...)' as follows:
> 
> ===============
> 
>         doctype = dom.createDocumentType ("", "", "");
> 
>         recordDoc = dom.createDocument ("", localName, doctype);
> 
> ===============
> 
> I've also tried using the keyword 'null' in place of the empty string, but
> to no avail.  Each attempt is met with a runtime exception
> "org.w3c.dom.DOMException: DOM002 Illegal character."
> 
> The reason I'm trying to create a null doctype is because for the time
> being, I have no desire to validate my documents, but wish to create (via
> the DOMImplementation) a new document with a dynamically-determined document
> element name.  I seem to recall the 'createDocument(...)' method blowing up
> if it receives a null doctype element - but I haven't tried that since
> Xerces 1.1 or so.

I'm not positive, but I don't think DOM allows you to create a Document
object without have a specific DocumentType in mind first.  There is a
way in JAXP, though, using the DocumentBuilderFactory.newDocument()
method.  Someone can correct me if I am wrong.

-Edwin

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