[xsd-users] How to iterate different childs of a node together

Boris Kolpackov boris at codesynthesis.com
Wed Mar 29 13:00:59 EST 2006


Hi Thomas,

Thomas Müller <th.mueller at weisang.com> writes:

> I have an element that basically looks like this:
>
> 	<xs:element name="item">
> 	     	<xs:complexType>
>             	<xs:choice minOccurs="0" maxOccurs="unbounded">
>                   	<xs:element name="subitem1">
> 					<xs:complexType>
> 						...
>                     		</xs:complexType>
>                   	</xs:element>
> 	                  <xs:element name="subitem2">
>       				<xs:complexType>
> 						....
> 					</xs:complexType>
>                   	</xs:element>
> 			</xs:choice>
> 		</xs:complexType>
> 	</xs:element>
>
> The generated iterators allow to iterate over all nodes of type subitem1 and
> subitem2 separately.
> Is there an easy way to iterate over all subitem-nodes (subitem1 and
> subitem2) in the sequence of their occurence?

The problem with such an iteration is that it is not clear what
type it should be based on. The only type that comes to mind is
xml_schema::type, from which all schema types derive.

Right now you can associate DOM nodes with your tree nodes (see
examples/cxx/tree/mixed on how to do this). With this, you will
be able to get a DOM node that corresponds to an 'item' and then
iterate over all sub-nodes in the sequence of their occurrence.
Though you won't be able to get "back" to the tree nodes (e.g.,
'subitem1' and 'subitem2') from DOM nodes. I don't, however, see
any technical difficulty in implementing this if somebody needs
it (i.e., store a pointer to xml_schema::type in DOM nodes). So
let me know if you need this.


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/20060329/2326d0d1/attachment.pgp


More information about the xsd-users mailing list