XSD <any> element

Joined
Jun 15, 2008
Messages
2
Reaction score
0
I am a novice with XML and XSD terminology and usage, but I have had some success using Notepad and Microsoft Word to create document content controls that are bound to custom XML. This lets me copy a control and paste it at other locations in a document. When one control is edited the edit is reflected in all contros.

Next I created and associated a schema to the document that validates the users entries in the controls.

My problem/question is "After created my mapped controls and associating the schema, how do I add additonal elements to the XML file that I don't want validated by the schema?"

My attempts to add additional controls using VBA results in a run-time error stating the action results in an invalid XML structure.

I thought that the XSD element "any" is supposed to allow the addion of elements that are not subject to validation.

Here is what the XML file looks like with just the one element "Age"

<ccMap xmlns="http://myForm">
<ccElement_Age xmlns="http://myForm">38</ccElement_Age>
</ccMap>

Here is the XSD file that I tried to use (that contains the "any" element) but attempting to add an additional element in the XML shown above results in the run time error mentioned above:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://myForm"
xmlns="http://myForm"
elementFormDefault="qualified">
<xs:element name="ccMap">
<xs:complexType>
<xs:sequence>
<xs:element name="ccElement_Age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:any minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

I am trying to be able to programatically add additional elements to the existing XML after associating the schema. For example, edit the XML to:

<ccMap xmlns="http://myForm">
<ccElement_Age xmlns="http://myForm">48</ccElement_Age>
<ccElement_Name xmlns="http://myForm">Greg</ccElement_Name>
</ccMap>

Can anyone explain how this should be done (if it can be done)? Thankd.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top