LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives


XML-L Archives

XML-L Archives


View:

Next Message | Previous Message
Next in Topic | Previous in Topic
Next by Same Author | Previous by Same Author
Chronologically | Most Recent First
Proportional Font | Monospaced Font

Options:

Join or Leave XML-L
Reply | Post New Message
Search Archives


Subject: Re: Reserved xml characters
From: "John E. Simpson" <[log in to unmask]>
Reply-To:General discussion of Extensible Markup Language <[log in to unmask]>
Date:Mon, 5 Feb 2001 09:08:13 -0500
Content-Type:text/plain
Parts/Attachments:
Parts/Attachments

text/plain (33 lines)


At 09:09 AM 02/05/2001 +0000, Joseph Lama wrote:
>For one of the text-fields in the form I noticed that the users are
>sometimes writing in reserved xml characters,"<" and "&" , which results in
>xml-parser errors.
>
>How should I declare such text-fields in my DTD instead of:
>
>  <!ELEMENT text-field (#PCDATA)>

As Paul Kelly said, there's nothing you can do in the DTD; #PCDATA is the
right content model for any text content, even if it contains the reserved
characters.

You've got two choices, both involving some kind of processing to occur
between the time the user enters data in the field and the time you load
the entry into your XML data store.

First, as Paul said, you can scan the entry, replacing every occurrence of
& and < with its "entitized" form.

Second, you can simply wrap the entire entry in a CDATA section, without
scanning it at all. The result passed downstream to whatever application is
handling the data will look like this:
    <![CDATA[entered data appears here]]>
While this is may be a simpler solution over the short run, it more or less
just delays the inevitable -- you'll need to "entitize" it at some point if
the data will be persisting in XML form.


================================================================
John E. Simpson          | "Is it weird in here, or is it just
http://www.flixml.org    | me?" -- Steven Wright
XML Q&A: www.xml.com     |

Back to: Top of Message | Previous Page | Main XML-L Page

Permalink



LISTSERV.HEANET.IE

CataList Email List Search Powered by the LISTSERV Email List Manager