You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Boris Kolpackov <bo...@codesynthesis.com> on 2006/09/08 18:14:43 UTC

Re: Creating a document from a schema

Hi Neil,

"Ferguson, Neil D" <Ne...@yuma.army.mil> writes:

> In my application I want to use xerces-c to create a skeleton of a DOM
> document  based on a schema containing default values for all elements.
> There would be no XML file to parse.  I would then find document nodes by
> name and set the element values programmatically to their actual values.
> After I have set the values I would then write the document to an XML file
> that has the necessary attributes to associate itself with the schema.

No, this not supported in Xerces-C++. It is also a not very well defined
problem in the general case. Imagine you have a schema like this:

  <xsd:complexType name="Foo">
    <xsd:sequence>
      <xsd:element name="bar" type="xsd:string" maxOccurs="10" default="bar"/>
    </xsd:sequence>
  </xsd:complexType>

How many bar elements should the default document contain, 0, 1, 10?

For what it's worth, our open-source XML data binding compiler[1] does
what you want but only for elements with cardinality "exactly 1" and
required attributes.


[1] http://www.codesynthesis.com/products/xsd/


hth,
-boris


-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding