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

Boris Kolpackov boris at codesynthesis.com
Fri Mar 31 04:01:06 EST 2006


Hi Thomas,

[I've CC'ed xsd-users back in; others may be interested in this info.]


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

> > Yes, I suppose it could be done this way. I am wondering how
> > useful such a feature would be in general. I think for now we
> > will just support getting back from DOM nodes (see below). If
> > more people ask for this, we will consider implementing it.
>
> To be honest, I don't know. I have at least one case here where I need
> it. I agree that in most cases the order of the elements either does not
> matter or there are only child nodes of the same type, but sometimes
> it can be crucial...

Agree. That's the main reason we implemented the optional DOM
association feature.


> I can live with the solution to switch to the tree and then back to the
> generated type system. Huge XML files might be a problem when the DOM tree
> is preserved, but the ones I use are usually quite small (~30 KB) so I
> don't care.

I agree that for big XML instances keeping DOM around could be
quite wasteful. If you run into such a situation please let me
know.


> 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.
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.

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/20060331/1ebd0b37/attachment.pgp


More information about the xsd-users mailing list