Print

Print


Hi Folks,

As I understand it, namespaces cannot be used in DTDs.  Hence, the best
that a person can do in an XML document that uses namespaces is to check
for well-formedness.  However, it seems to me that an XML parser should be
able to validate individual pieces of the XML document.  Namely, it should
be able to validate the portion that uses the namespace. For example:

<?xml version="1.0"?>
<library>
    <personnel>
          ...
    </personnel>
    <BookCatalog xmlns="http://rogersPC/BookCatalog.dtd">
          ...
    </BookCatalog>
</library>

An XML parser should be able to validate

    <BookCatalog xmlns="http://rogersPC/BookCatalog.dtd">
          ...
    </BookCatalog>

to see if this portion properly follows the grammar defined in
BookCatalog.dtd.

My experience is that parsers do not do any validation.  The reason I say
this is that in BookCatalog.dtd I have defined some ENTITYs, such as

<!ENTITY BTW "by the way">

When I use the entity in my XML document:


    <BookCatalog xmlns="http://rogersPC/BookCatalog.dtd">
          ...
          <Description>Oh, &BTW; he said that ... </description>
          ...
    </BookCatalog>

The XML parse gives an error, saying that it is unfamiliar with the entity
BTW.  (I got this error message both with msxml and IBM's xml4_j XML
parsers.)  So, that led me to believe that XML parsers do not validate
those portions of an XML document that use namespaces.  Are there XML
parsers that do in fact validate portions of the document?  Comments?
/Roger