[xsd-users] Howto to use an attribute as an index to a sequence
Boris Kolpackov
boris at codesynthesis.com
Wed Dec 12 23:23:18 EST 2007
Hi Thomas,
Thomas Maenner <tmaenner at aehr.com> writes:
> The output should be:
> 0: String0
> 1: String2
> 2: String1
> and not:
> 0: String0
> 1: String1
> 2: String2
This code should do it:
test_root::node_sequence& ns( t->node() );
for( unsigned int i=0; i < ns.size(); i++ )
{
nodeType& n (ns[i]);
unsigned int j = n.unIndex ().present () ? n.unIndex ().get () : i;
cout << i << ": " << ns[j].strTest() << endl;
}
Or the same using the pointer notation:
unsigned int j = n.unIndex () ? *n.unIndex () : i;
Boris
More information about the xsd-users
mailing list