[xsd-users] counting attribute
Boris Kolpackov
boris at codesynthesis.com
Wed Jul 11 12:03:06 EDT 2007
Hi Uri,
Uri Karagila <uri at hyperroll.com> writes:
> Lets assume I have an xsd complex type element/object which own multiple
> attributes (some are `optional=true` and other are not).
>
> My questions are:
>
> 1. What would be the best way to count the number of "present"
> attributes of a random object?
The best way would be to keep the DOM tree associated with the
object model and then, when you need to count the attributes,
call _node() to obtain the pointer to DOMNode that corresponds
to this tree node and count the present attributes.
> 2. is there a structured way to "go over" existing attributes of
> random object?
Yes, using the Xerces-C++ DOM interface. Note that you can also "get
back" from a DOM node to the corresponding tree node by obtaining and
casting the user data pointer with the xml_schema::tree_node_key key.
For more information on DOM association, see the mixed example in the
examples/cxx/tree/ directory and read Section 3.2, "Flags and Properties"
in the manual.
hth,
-boris
More information about the xsd-users
mailing list