[xsde-users] sequence and any element

dvjuorw+sqsv74 at guerrillamail.com dvjuorw+sqsv74 at guerrillamail.com
Fri Sep 21 00:35:37 EDT 2012


I am looking into xsde to see if I can use XML to configure my tiny linux box.  It requires:
1.  any defined element in schema cannot be removed but the xml file may not contain all defined element.
2.  the xml file may contain elements that are not defined in the schema.

I modified the wildcard example (email.xml, email.xds and driver.cxx) of xsde.  I try to achieve:
1.  if email.xml does not contain "from" element, will the parser skip the missing elements and validate next element?
2.  if an unknown element "abc" is found in email.xml, will the parser ignore the unknown elements?

The test code returns "expected element not encountered".  It seems the test code expects a "from" element from email.xml.  Do I break any XML rule or xsde does not support it?

Regards,
kk


email.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:eml="http://www.codesynthesis.com/email"
            targetNamespace="http://www.codesynthesis.com/email">

  <!-- Predefined envolop body types. -->

  <xsd:element name="text" type="xsd:string"/>

  <xsd:complexType name="binary">
    <xsd:simpleContent>
      <xsd:extension base="xsd:base64Binary">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="mime" type="xsd:string" use="required"/>
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>

  <xsd:element name="binary" type="eml:binary"/>

  <xsd:complexType name="envelope">
    <xsd:sequence minOccurs="0">
      <xsd:element name="to" type="xsd:string"/>
      <xsd:element name="from" type="xsd:string"/>
      <xsd:element name="subject" type="xsd:string"/>

      <!-- Extensible envelope body. -->

      <xsd:any namespace="##any" processContents="skip"
                minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="message" type="eml:envelope"/>

</xsd:schema>


email.xml

<?xml version="1.0"?>

<!--

file      : examples/cxx/hybrid/wildcard/email.xml
author    : Boris Kolpackov <boris at codesynthesis.com>
copyright : not copyrighted - public domain

-->

<eml:message xmlns:eml="http://www.codesynthesis.com/email"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	     xsi:schemaLocation="http://www.codesynthesis.com/email email.xsd">

  <to>Jane Doe &lt;jane at doe.com></to>

  <subject>Surfing pictures</subject>
  <abc>123</abc>
  <eml:text>
Hi Jane,

Here are cool pictures of me surfing.

Cheers,
John
  </eml:text>

  <eml:binary name="pic1.jpg" mime="image/jpeg">YmFzZTY0IGJpbmFyeQ==</eml:binary>
  <eml:binary name="pic2.jpg" mime="image/jpeg">YmFzZTY0IGJpbmFyeQ==</eml:binary>

</eml:message>


driver.cxx - commented out the section that prints the content and generates a reply

...
#if 0
    // Print what we've got.
    //
    cerr << "To:      " << msg->to () << endl
         << "From:    " << msg->from () << endl
         << "Subject: " << msg->subject () << endl;
....
    message_s.pre (*reply);
    doc_s.serialize (cout, xml_schema::document_simpl::pretty_print);
    message_s.post ();
#endif
  }
  catch (const xml_schema::parser_exception& e)
  {





More information about the xsde-users mailing list