[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Wellformedness

  • From: Richard Tobin <richard@c...>
  • To: xml-dev@l...
  • Date: Tue, 13 Mar 2001 23:32:38 +0000 (GMT)

wellformedness
<?xml version="1.0"?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA)>
%zz;
<!ENTITY % zz '&#60;!ENTITY nonTricky "error-prone" >' >
]>
<test>
    &nonTricky;
</test>

First, the problem with this is that the parameter entity zz is
used before it is defined.  But what kind of error is it?

Technically, the document is well-formed but invalid.  This is because
the rule that parameter entities must be defined before they are used
is a validity constraint, rather than a well-formedness constraint.

If I understand correctly, the only reason it is a validity constraint
is to avoid the situation where a minimal processor, which doesn't
read the external subset, detects an error that a validating parser
doesn't.  This would happen if zz was externally defined,
for example:

<!DOCTYPE test [
<!ELEMENT test (#PCDATA)>
<!ENTITY % moredtd SYSTEM "more.dtd">
%more.dtd;
%zz;

where more.dtd contained a definition of zz.  This is perfectly legal,
but a minimal parser won't see the definition of zz, and thus can't
tell when it sees the reference to zz whether it is an error or not.

On the other hand, it is natural for a parser that *does* read the
external subset - and thus knows for sure whether the entity is
defined - to treat it as a fatal error.  I would expect most parsers
that process parameter entities to give up when they encounter the
undefined entity, even though it is technically only a validity
error.  Certainly mine (RXP) does.

To answer some of your other questions:

> Are internal DTDs mandatory to parse when only checking wellformedness?

All processors must process the internal subset.  Non-validating
parsers need not expand parameter entity references (which can only
occur at top level in the internal subset, and are thus easily
skipped).  If they don't expand a parameter entity reference, they
must not process any declarations after it (because the parameter
entity may contain declarations which override the later ones).

>Are internal entities required to be included if only checking
>wellformedness?

Parameter entities, whether internal or external, need not be expanded
by non-validating processors.  (Internal *general* entities must
always be expanded.)

-- Richard

  • References:

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.