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

Thomas Müller th.mueller at weisang.com
Fri Mar 31 06:44:49 EST 2006


Hi Boris,

> 
> > In case you decide to implement it as an option: I think it should 
> > suffice to generate it on demand for dedicated 
> elements/types given on 
> > the command line. To add a generic sequence for all nodes 
> is probably unnecessary.
> 
> Agree. There, however, could be some overall changes and 
> overheads involved in order to support this. For example, 
> with this feature, an instance is now contained (or, rather, 
> referenced) in two containers. This will require some sort of 
> reference counting. Also things get tricky when you start 
> considering tree modifications.

If the references in the generic sequence would be considered
as weak it should be possible to come away without ref counting...

Tree modifications could be a real issue. I currently just
read and process the files so I had not in mind to modify them.

> For example, it is not always clear where to insert a new 
> member in the sequence of all members. In general case, one 
> will have to analyze the corresponding schema to figure out 
> where to insert things. Consider, for instance, the following 
> simple case:
> 
> <element name="foo">
>   <comlexType>
>     <sequence maxOccurs="unbounded">
>       <element name="one" type="string"/>
>       <element name="two" type="int"/>
>     </sequence>
>   </comlexType>
> </element>
> 
> Let's say we started with the following instance
> 
> <foo>
>   <one>a</one>
>   <two>1</two>
> </foo>
> 
> The sequence of all members is 'a 1'. Now we first insert 
> element 'two'
> 
> foo ().two ().push_back (2);
> 
> The sequence becomes 'a 1 2'. Now we insert element 'one':
> 
> foo ().one ().push_back ("b");
> 
> In order to be valid per schema we will need to insert 'b' before '2':
> 'a 1 b 2'. So such insertion should be schema-guided.

I am not quite sure if I understand this. My XML files are validated
against their schema when they are loaded, so if I have them in memory 
and iterate over the childs of a node from left to right this should
always be 'a 1 b 2'. Everything else should be rejected in advance.

Thomas





More information about the xsd-users mailing list