W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2003

Problem with Element Definition and XML CDATA

From: Matthew Jaquish <mjaquish@cisco.com>
Date: Wed, 08 Jan 2003 14:41:38 -0800
Message-Id: <>
To: xmlschema-dev@w3.org

Hello all!

If this message is a duplicate, I sincerely apologize. I searched through the archives and could not find an answer to my question, which is:

Can I define an element to contain a string OR a CDATA section, and not contain an empty string? In a schema, is there any way to allow an element to contain CDATA? I couldn't find it in the specification.

My problem: When I use an element definition and set it to a string datatype with a minimum length of 1, I get a validation error when it contains a CDATA section. I want to allow a string or a CDATA section as valid content for the same element, and I do not want to allow it to be blank.

Here are examples of what I want to allow:
    <description>some text or numbers 1234</description>
    <description><![CDATA[anything in the CDATA section]]></description>

Here is an example of what I do NOT want to allow:

I tried this, which works for a string, but tells me that a CDATA section is invalid:
    <xsd:element name="description">
        <xsd:restriction base="xsd:string">
          <xsd:minLength value="1"/>

Is it possible to define this combination for an element in a schema?


- Matt
Received on Wednesday, 8 January 2003 18:00:07 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:59 UTC