[xsd-users] xsd:any in parser

Boris Kolpackov boris at codesynthesis.com
Mon May 21 15:13:20 EDT 2007


Hi Jiri,

Jiri Poledna <jiripoledna at seznam.cz> writes:

>      <xsd:element name="Reviewer">
>        <xsd:complexType>
>          <xsd:sequence>
>            <xsd:element name="Name" type="xsd:string">
>            </xsd:element>
>          </xsd:sequence>
>        </xsd:complexType>
>      </xsd:element>
>      <xsd:element name="root">
>        <xsd:complexType>
>          <xsd:sequence>
>            <xsd:element name="Title">
>              <xsd:complexType>
>                <xsd:attribute name="SchemaVersion" type="xsd:string" default="3.0.3" />
>                <xsd:attribute name="ID" type="xsd:string" use="required"/>
>              </xsd:complexType>
>            </xsd:element>
>            <xsd:any namespace="##any" processContents="skip" />
>          </xsd:sequence>
>        </xsd:complexType>
>      </xsd:element>
>
>    I'm using xsd.exe utility to generate the hxx and txx, I obtained
>    parserhooks to Title element, but I do not reach Reviewer element.

The hooks you are interested in are:

virtual void
_start_any_element (const xml_schema::ro_string& ns,
                    const xml_schema::ro_string& name);

virtual void
_end_any_element (const xml_schema::ro_string& ns,
                  const xml_schema::ro_string& name);

virtual void
_any_attribute (const xml_schema::ro_string& ns,
                const xml_schema::ro_string& name,
                const xml_schema::ro_string& value);

virtual void
_any_characters (const xml_schema::ro_string&);


They pretty much constitute SAX events and are triggered for elements,
attributes, and text of wildcard/mixed content. In your case, you will
need to override them in the implementation of the Title parser. The
Reviewer element (in place of an any) and all its nested contents will
be delivered via these hooks.


hth,
-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/20070521/37977f9b/attachment.pgp


More information about the xsd-users mailing list