Parameter Entity Replacement and the XML 1.0 Grammar

G. Ken Holman gkholman at
Wed Nov 17 15:25:14 GMT 1999

Hi folks!

Down below I have an example extrapolated from working markup I've been 
using with XT for months.

To parameterize my production environment, I use parameter entities quite a 
bit, as you can see in the file "test.ent".

XT has been accepting this declaration of NDATA entities, giving me the 
equivalent as if the replacement values were correctly replaced.

Today I started using a validating parser on the source file and it is 
choking on the entity declaration.

I immediately thought the new parser I was using was at fault, but thought 
I'd check XML 1.0 and saw that perhaps parameter entity references are not 
allowed according to the grammar:

[71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'

[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)

[75] ExternalID ::= 'SYSTEM' S SystemLiteral

[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")

[76] NDataDecl ::= S 'NDATA' S Name

[5] Name ::= (Letter | '_' | ':') (NameChar)*

[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | 

But .... according to 4.4.8 parameter entity references can wholly replace 
integral grammatical tokens, so perhaps the use of parameter entity 
references is *outside* the grammar productions of XML 1.0.

So, my question is:  Does 4.4.8 take precedence over the grammar 
productions (the new parser is incorrect), or is the behaviour I am used to 
not correct (XT is incorrect)?

My belief is I've been working properly all along, XT is correct, and the 
new parser is incorrect.

Thanks for any help you can be.

............. Ken

T:\ftemp>type test.xml
<?xml version="1.0"?>
<!DOCTYPE doc [
<!ENTITY % test SYSTEM "test.ent">
]><doc file="abc"/>
T:\ftemp>type test.ent
<!ENTITY % e "wmf"><!--non .gif extension-->
<!ENTITY % filename "'abc.%e;'">
<!ENTITY abc SYSTEM %filename; NDATA %e;>
<!--end of file-->
T:\ftemp>type test.xsl
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet []>
<xsl:stylesheet xmlns:xsl=""

<xsl:output method="text"/>

<xsl:template match="/doc">
   Value is: <xsl:value-of select="unparsed-entity-uri(@file)"/>


T:\ftemp>xt test.xml test.xsl test.txt

T:\ftemp>type test.txt

   Value is: file:/T:/ftemp/abc.wmf
T:\ftemp>call xml test.xml
Parsing: 'test.xml' for XML errors
[Fatal Error] test.ent:4:21: The system identifier must begin with either a 
single or double quote character.


G. Ken Holman                    mailto:gkholman at
Crane Softwrights Ltd.   
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-02-0
Next instructor-led training:              1999-12-05/06, 1999-12-07,
-                            2000-02-27/28, 2000-05-11/12, 2000-05-15

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list