[xsd-users] Howto to use an attribute as an index to a sequence

Thomas Maenner tmaenner at aehr.com
Wed Dec 12 23:44:02 EST 2007


Ha... cool... seems to work - Thanks!

You're up early... Cheers
Tom

On Wednesday 12 December 2007, Boris Kolpackov wrote:
> 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



-- 
Thomas Maenner
E-Mail: mailto:tmaenner at aehr.com




More information about the xsd-users mailing list