By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,386 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,386 IT Pros & Developers. It's quick & easy.

Restricting the length of a CDATA section value.

P: 1
Hi all,

I have an XML file where all to elements for the data are contained in CDATA sections. I have a schema created that is working right now although it is pretty dumbed down. I have a need now to insert into the schema a restriction on the length of the values in the different elements.

The xml looks like this;

Expand|Select|Wrap|Line Numbers
  1. <DOC_CAT Attribute="Y"><![CDATA[AR]]></DOC_CAT>
The schema for this field currently looks like this;

Expand|Select|Wrap|Line Numbers
  1. <xs:element name="DOC_CAT">
  2.  <xs:complexType mixed="true">
  3.   <xs:attribute name="Attribute" use="required">
  4.    <xs:simpleType>
  5.     <xs:restriction base="xs:string">
  6.      <xs:enumeration value="Y"/>
  7.     </xs:restriction>
  8.    </xs:simpleType>
  9.   </xs:attribute>
  10.  </xs:complexType>
  11. </xs:element>
I have tried putting a maxLength parameter just above the enumeration parameter, but nothing happens when I validate the xml with a field value that is longer than the maxLength parameter. My suspicion is that the maxLength parameter is being applied to the attribute field instead of the cdata section.

How can I apply a length restriction against the value in the cdata section?

Thanks for your help,

Doug Harding
State of Utah
Sep 27 '05 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.