Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: DTDs and XML: another "not well formed" question

From: richard@------.--.--.-- (------- -----)
To: NULL
Date: 7/1/2007 5:47:00 PM

In article <1183310598.504725.29160@n...>,
seven.reeds <seven.reeds@g...> wrote:

><!ELEMENT article (title, image*, text+)>
><!ELEMENT title   (#PCDATA)>
><!ELEMENT image   (src, width?, height?, link?)>
>    <!ATTLIST src    CDATA #REQUIRED>
>    <!ATTLIST link   CDATA #IMPLIED>
>    <!ATTLIST width  PCDATA #IMPLIED>
>    <!ATTLIST height PCDATA #IMPLIED>

Are src, link, width and height subelements or attributes?
You've listed them as child elements in the content model, and
then declared them as attributes.

You seem to be using attributes, so declare image as

  <!ELEMENT image EMPTY>

And you've declared width and height as PCDATA which doesn't mean
anything; presumably you meant CDATA.

><!ELEMENT text    (#CDATA)>

And here you've declared the content of text to be #CDATA, presumably
you meant #PCDATA.

>A sample xml doc looks like
>
><?xml version="1.0" ?>
><!DOCTYPE article SYSTEM "http://www.itg.uiuc.edu/publications/news/
>news.dtd">
><article>
>  <title> Applied Physics Letters Features ITG Image on Cover </title>
>  <image link="http://scitation.aip.org/dbt/dbt.jsp?
>KEY=APPLAB&Volume=90&Issue=21"

All your ampersands need to be replaced with &amp;

>    src="/images/apl_cover-130.jpg" />
>  <text> The cover for the <a href="http://scitation.aip.org/dbt/
>dbt.jsp?KEY=APPLAB&Volume=90&Issue=21">May

Your dtd doesn't say anything about <text> being allowed to contain
<a> elements.  You'll need to change the declaration of text and add
a declaration for a.

>My XML parser chokes on the first "&" (ampersand) in the "link"
>attribute of the "image" tag.  I know that being "well-formed" means
>the amps should be "quoted" but I thought that the "CDATA bits in the
>DTD meant that *ALL* characters are accepted in this context.

A CDATA marked section in text, such as <![CDATA[hello & goodbye]]>
has that effect.  In attributes (whether declared as CDATA or something
else) you have to quote ampersands.  There's no way around it.

The CDATA/PCDATA terminology is certainly confusing.

-- Richard
-- 
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent