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

DTD parameter entities


dtd parameter entity
I'm implementing parameter entity support for my XML parser (well I guess 
it can be truly called
XML parser when I've finished implementing this and some other DTD 
processing parts).

I think I understand what the XML 1.0 spec and 4.4 XML Processor Treatment 
of Entities and References
says about parameter entities - 4.4.5 Included in Literal etc. is easy to 
implement of course and
4.4.8 Included as PE seems quite clear; it says that parameter entity 
references can occur anywhere in DTD
but the fact that expansion will insert space (#x20) to the start and to 
the end of the expanded value places
some limitations for construct like
<!ENTITY % ENT "<!ENT">
<!ENTITY % ITY "ITY">
%ENT;%ITY; blaah "value"> <!-- will not work because it will expand to 
<!ENT ITY -->


I used the following petest.dtd for testing how various parsers work:
(PE references %ELEMNAME;%ATTNAME; are contiguous on purpose - there'll be 
space
between them when they're expanded)

<!ENTITY % ATTLIST "<!ATTLIST ">
<!ENTITY % CLOSE ">">
<!ENTITY % ELEMNAME "doc">
<!ENTITY % ATTNAME "att">
%ATTLIST; %ELEMNAME;%ATTNAME; CDATA #FIXED "value"%CLOSE;

the petest.xml doc was simple:
<!DOCTYPE doc SYSTEM "petest.dtd">
<doc/>

results (validation was off):
- RXP 1.4.0pre10: ok
- Expat 1.9.6: ok
- Xerces-J 2.6.2:
[Fatal Error] petest.dtd:8:10: The replacement text of parameter entity 
"%ATTLIS
T" must include properly nested declarations when the entity reference is 
used a
s a complete declaration.

Works fine if %ATTLIST; reference is replaced with <!ATTLIST i.e.
<!ATTLIST %ELEMNAME;%ATTNAME; CDATA #FIXED "value"%CLOSE;

- MSXML4 (version ?):
The replacement text for a parameter entity must be properly nested
with parenthesized groups. Error processing resource 'petest.dtd'.
Line 6, Position 10

doesn't even work if %ATTLIST; is replaced - will trigger error in %CLOSE;
this works:
<!ATTLIST %ELEMNAME;%ATTNAME; CDATA #FIXED "value">


Is there something I'm missing? Implementing parameter entity support
seems quite trivial (common design stage optimism perhaps ;-) )
but seeing how various parsers react I'm not quite sure if it'll be trivial 
at all.


with respect,
Toni Uusitalo



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.