Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: add CDATA element to an xml schema?

From: Peter Flynn <peter.no-sp@-.--------.-->
To: NULL
Date: 11/1/2004 10:48:00 PM
X. Lee wrote:

> I am creating an xml schema, and I want one of the elements to include
> html text.  

You mean HTML markup? In general, this is A Bad Idea. If the markup is
important, represent it in the schema. If it's not, remove it.

> Therefore, I want to make that element a CDATA elements so
> that it can accept html tags as part of it's value.  I'm having
> trouble doing this though.  Can anyone give me a sample of how to do
> that?

You can't do this in XML. If you want to declare CDATA content you have
to use SGML instead, eg

   <!element foo - - CDATA>

but even so most SGML parsers will reject any attempt to use an end-tag
inside the element. 

> so if this is my xml instance:
> 
> <root>
> <element><!CDATA[something]]></element>
> </root>
> 
> how would I create an xml schema so that my instance is valid against
> that schema?

Doing it that way (with a manually-inserted CDATA Marked Section) is fine
(except you're missing an open-square bracket before the keyword CDATA).
The instance will always be valid, because the parser will suspend the
recognition of < and & until it encounters ]]>. 

///Peter
-- 
"The cat in the box is both a wave and a particle"
      -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_


transparent
Print
Mail
Digg
delicious
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