Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSD <any> element

Reply
Thread Tools

XSD <any> element

 
 
gmaxey@mvps.org gmaxey@mvps.org is offline
Junior Member
Join Date: Jun 2008
Posts: 2
 
      06-15-2008
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 xmlnss="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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD restriction of nesting an element within another element with aspecific attribute value? PeteOlcott XML 1 02-05-2009 06:39 AM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
XML + XSD: Is it possible to get all errors against the XSD? Markus Java 1 11-22-2005 02:53 PM
XSD document for XSD defintion Rick Razzano XML 1 09-26-2003 12:41 AM
XSD - element, element value and attribute ? Matthet XML 2 09-24-2003 04:10 PM



Advertisments