Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Small DTD question

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: "Trimmer, Todd" <todd.trimmer AT trizetto.com>, "'xom-interest AT lists.ibiblio.org'" <xom-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: Re: [XOM-interest] Small DTD question
  • Date: Thu, 15 May 2003 13:25:26 -0400

At 11:03 AM -0600 5/15/03, Trimmer, Todd wrote:
If I try parsing the following XML with validation:


<?xml version="1.0"?>
<!DOCTYPE cool [
<!ELEMENT cool ANY>
]>
<cool>
<b />
</cool>


I get a validation error saying "b" is not declared.

What is the point of using ANY, then, if I don't have the freedom to place
whatever I want under "cool"? When does ANY ever become useful?

Your problem is not with XOM. This is an XML issue. ANY means that you can have any declared element, not any element at all. (Of course, you can have any element at all. The document just wouldn't be valid.)

What if all I want to do is allow some character entities in my document,
but do not want to restrict the element/attribute content in any way?

That's fine. Do that. It will work. Validity is optional, not required. XOM always resolves entity references. It will only validate if you tell it to do so. (though now that you mention it, I wonder is there should be a way to parse a document while validating without throwing an exception. Hmm, I need to think about that.)
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page