[xsd-users] RFC: wildcard mapping for C++/Tree

Boris Kolpackov boris at codesynthesis.com
Wed May 23 06:13:05 EDT 2007


Hi,

As promised, below is an overview of the proposed wildcard (xsd:any
and xsd:anyAttribute) mapping for C++/Tree that we plan to implement
for 3.0.0. Your comments on this proposal will be very much appreciated.

For each wildcard a set of accessor and modifier functions will be
generated that will allow accessing content matched by a wildcard as
DOMElement (for element wildcard) and DOMAttr (for attribute wildcards).
The names for the functions will be automatically selected in the form
any, any1, etc., for element wildcards (xsd:any) and any_attribute,
any_attribute1, etc. for attribute wildcards (xsd:anyAttribute).

Since xsd:anyAttribute can match any number of attributes, its mapping
will be to a set of DOMAttr nodes with the key being the attribute name.

For xsd:any all three cardinality classes (one, optional, and sequence)
are possible and the mapping will be similar to that of elements.

Since Xerces-C++ DOM nodes always belong to a DOMDocument, each type
with a wildcard will have a DOMDocument instance. This instance will
be available via an accessor function called dom_document. The access
to DOMDocument from user code will be necessary to create/modify
wildcard content.

Here is an example:

<complexType name="Type">
  <sequence>
    <any namespace="##other"/>
  </sequence>
  <anyAttribute namespace="##other"/>
</complexType>


class Type
{
public:
  const DOMDocument&
  dom_document () const;

  DOMDocument&
  dom_document ();

  // any
  //
  const DOMElement&
  any () const;

  DOMElement&
  any ();

  void
  any (const DOMElement&); // copy

  void
  any (DOMElement*); // assume ownership


  // anyAttribute
  //
  typedef set<DOMAttr> any_attribute_container;
  typedef any_attribute_container::iterator any_attribute_iterator;
  typedef any_attribute_container::const_iterator any_attribute_const_iterator;

  const any_attribute_container&
  any_attribute () const;

  any_attribute_container&
  any_attribute ();

  void
  any_attribute (const any_attribute_container&);
};


void
f (Type& t)
{
  DOMElement& e (t.any ());
  e.appendChild (t.dom_document ().createElement ("attr"));

  t.any_attribute ().insert (t.dom_document ().createAttribute ("attr"));
}


thanks,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070523/06df1979/attachment.pgp


More information about the xsd-users mailing list