Restricting length in CDATA section value.

  • 15 years ago

    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;


    <DOCCAT Attribute="Y"><![CDATA[AR]]></DOCCAT>


    The schema for this field currently looks like this;


    <xs:element name="DOC_CAT">
    <xs:complexType mixed="true">
     <xs:attribute name="Attribute" use="required">
      <xs:simpleType>
       <xs:restriction base="xs:string">
        <xs:enumeration value="Y"/>
       </xs:restriction>
      </xs:simpleType>
     </xs:attribute>
    </xs:complexType>
    </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

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“God could create the world in six days because he didn't have to make it compatible with the previous version.”