XSD <any> element

Discussion in 'XML' started by gmaxey@mvps.org, Jun 15, 2008.

  1. gmaxey@mvps.org

    gmaxey@mvps.org

    Joined:
    Jun 15, 2008
    Messages:
    2
    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.
     
    gmaxey@mvps.org, Jun 15, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,169
    Markus
    Nov 22, 2005
  2. Matthet
    Replies:
    2
    Views:
    697
    Matthet
    Sep 24, 2003
  3. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    520
    C. M. Sperberg-McQueen
    Sep 26, 2003
  4. Peter Aberline

    xsd:any as a child of xsd:all

    Peter Aberline, Apr 5, 2004, in forum: XML
    Replies:
    0
    Views:
    815
    Peter Aberline
    Apr 5, 2004
  5. PeteOlcott
    Replies:
    1
    Views:
    964
    Mukul Gandhi
    Feb 5, 2009
Loading...

Share This Page