473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

DTD and parameter entity replacement

Hello!

I have a simple question about DTDs: Should this be possible?

<!DOCTYPE root [

<!ELEMENT root (#PCDATA)>

<!ELEMENT this EMPTY>
<!ELEMENT that EMPTY>
<!ENTITY % param "that">

<!ELEMENT test (this, %param;)>
]


In the XML specification I can't find the spot where it says this would
be disallowed; however Xerces complains about the parameter entity being
in markup.

- Tuomas
Jun 9 '06 #1
3 1503
>In the XML specification I can't find the spot where it says this
would >be disallowed

In section 2.8, down a little ways:

"Well-Formedness Constraint: PEs in Internal Subset
In the internal DTD subset, parameter-entity references can occur only
where markup declarations can occur, not within markup declarations.
(This does not apply to references that occur in external parameter
entities or to the external subset.)"

Tim Bray's _Annotated_XML_Specification_
(http://www.xml.com/axml/testaxml.htm) has a comment on why this rule
was put in place. (That site is an excellent resource for understanding
why XML 1.0 is as it is. Unfortunately, Tim has said he probably won't
have time to bring it up to date for XML 1.1, never mind namespaces and
so on. There's an opportunity here for someone to contribute to the
community.)

For what it's worth, Appendix D shows a hideous workaround, which
involves constructing the whole entity definition in a single parameter
entity and using that. To find it, search for "error-prone" -- which it
is, and I strongly recommend that you find another solution.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 9 '06 #2
Tuomas Rannikko wrote:
Hello!

I have a simple question about DTDs: Should this be possible?
Yes, but not in an Internal Subset.
<!DOCTYPE root [

<!ELEMENT root (#PCDATA)>
This should probably be "test", not "#PCDATA".
<!ELEMENT this EMPTY>
<!ELEMENT that EMPTY>
<!ENTITY % param "that">

<!ELEMENT test (this, %param;)>
]
>


In the XML specification I can't find the spot where it says this would
be disallowed; however Xerces complains about the parameter entity being
in markup.


Joe has pointed out where. Just snip out the declarations and put them
in test.dtd (with the content model for "root" being "test"), then

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE root SYSTEM "test.dtd">
<root>
<test>
<this/>
<that/>
</test>
</root>

is a valid instance.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jun 10 '06 #3
Joe Kesselman wrote:
>In the XML specification I can't find the spot where it says this

would >be disallowed

In section 2.8, down a little ways:

"Well-Formedness Constraint: PEs in Internal Subset
In the internal DTD subset, parameter-entity references can occur only
where markup declarations can occur, not within markup declarations.
(This does not apply to references that occur in external parameter
entities or to the external subset.)"

Tim Bray's _Annotated_XML_Specification_
(http://www.xml.com/axml/testaxml.htm) has a comment on why this rule
was put in place. (That site is an excellent resource for understanding
why XML 1.0 is as it is. Unfortunately, Tim has said he probably won't
have time to bring it up to date for XML 1.1, never mind namespaces and
so on. There's an opportunity here for someone to contribute to the
community.)


Ah, yes. I seem to have mixed up my concepts. I had trouble seeing as to
why that would not be allowed, but the annotated specification helps to
clarify that it's allowed ONLY in external subsets (and why).

I guess I'll have to keep track whether I'm parsing an external or
internal subset. (I'm writing a parser just for the fun of it ;) )

Thanks,
- Tuomas
Jun 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steven Simpson | last post by:
Hello, If an XML processor encounters a 'PEReference' in a 'markupdecl' (but not in 'EntityValue'), are there circumstances where it does not have to include it (i.e. use the replacement text...
4
by: Laszlo Csabi | last post by:
Hi Folks, Can someone explain me why I'm getting the following error? The error message I got is : "Parameter count does not match Parameter Value count."
4
by: Erwin Gabler | last post by:
Trying to validate a document with a reference to a DTD ("PUBLIC" identifier): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE systems-description PUBLIC "-//foo/nono" ""> .... The DTD uses...
4
by: terry | last post by:
could someone tell me how to add or remove entity to a xml file when i dim xmlentity as new xmlentity it's say it's sube new is private thks
0
by: Frederico Guimar??es via DotNetMonster.com | last post by:
Hi, I'm trying to use the Microsoft.Web.Services2.Messaging. ISoapFormatter but I receive this error: System.Xml.XmlException: Reference to undeclared parameter entity, 'meetingmaker'. at...
4
by: Max | last post by:
I am writing a XML parser in Javascript and i have difficulty to understand the specifics of some "entities". I would want to understand the way in which the non-validating XML Parsers manage...
6
by: Tuomas Rannikko | last post by:
Hello, I'm currently writing a XML processor for the fun of it. There is something I don't understand in the spec though. I'm obviously missing something important. The spec states that both...
9
by: Max | last post by:
Hello! I would want to know if attributes values can be entity references and if the parser, during processing, can replace with blank string a non registered entity. Eg: <example...
1
by: kanepart2 | last post by:
Hey all , I wanted to create a project or item template in C# such that when I use that template a parameter wizard comes up asking for values. I know how to create the template without...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.