ksublondie has asked for the wisdom of the Perl Monks concerning the following question:
BACKGROUND: I'm using XML::Compile::Schema to read multiple xsd files and generate a hash of the contents with the template function.
QUESTION: I've never seen bless used in this context and definitely never nested like this. The concept of bless is still a little obscure to me. I guess I learn the best from example code. Since I haven't found any yet used in this way, I'm completely stumped as to why bless was used and what is the best way to access these elements? I'm able to drill down the structure just like it's a typical HOA, but why bless? I'm assuming bless is doing something special here, but I can't figure it out. Can someone shed some light for me?
The resulting LOG shows:my $xsd=XML::Compile::Schema->new(\@array); my $t= $xsd->template('TREE',$xsd->elements()); print LOG Dumper($t);
$VAR1 = { 'attrs' => [], ... 'elems' => [ bless( { 'struct' => [...], 'elems' => [ { ... }, { 'attrs' => [], 'elems' => [ bless( { ' +struct' => [...], ' +elems' => [ + { + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless( { + 'struct' => [ + ... + ], + 'elems' => [ + { + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [ + + ..., + + 'elems' => [ + + { + + ... + + }, + + { + + ... + + }, + + { + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + ..., + + 'elems' => [ + + { + + 'attrs' => [], + + 'elems' => [ + + bless( { + + 'struct' => [...], + + 'elems' => [ + + {...}, + + {...} + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + + ], + + ... + + }, + + { + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [ + + ... + + ], + + 'elems' => [ + + { + + ... + }, + + { + + ... + + }, + + { + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [ + + ... + + ], + + 'elems' => [ + + { + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + }, + { + ... + } + ], + 'tag' => 'sequence' + }, 'BLOCK' ) + ], + ... + } + ], ' +tag' => 'sequence' }, +'BLOCK' ) ], ... }, { 'attrs' => [], 'elems' => [ bless( { ' +struct' => [ + ... + ], ' +elems' => [ + { + 'attrs' => [], + 'elems' => [ + bless( { + 'struct' => [ + ... + ], + 'elems' => [ + { + ... + }, + { + ... + }, + { + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [... ], + + 'elems' => [ + + { + + ... + + }, + + { + + ... + + }, + + { + + ... + + }, + + { + + ... + + }, + + { + + ... } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [...], + + 'elems' => [ + + { ... + }, + + { + + 'attrs' => [], + + 'elems' => [ + + bless( { + + 'struct' => [... + + ], + + 'elems' => [ + + {...}, + + {...}, + + { + + ... + }, + + { + + ... + + }, + + { + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + + ], + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + }, + { + ... + }, + { + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [...], + + 'elems' => [ + + { + + 'attrs' => [], + + 'elems' => [ + + bless( { + + 'struct' => [...], + + 'elems' => [ + + { ...}, + + {...}, + + {...} + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + + ], + + ... + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + }, + { + ... + }, + { + ... + } + ], + 'tag' => 'sequence' + }, 'BLOCK' ) + ], + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless( { + 'struct' => [...], + 'elems' => [ + {...}, + {...}, + {...}, + {...}, + {...}, + {...}, + {...} + ], + 'tag' => 'sequence' + }, 'BLOCK' ) + ], + ... + }, + { + 'attrs' => [], + 'elems' => [ + bless( { + 'struct' => [...], + 'elems' => [ + {...}, + {...}, + {...}, + {...}, + { + 'attrs' => [], + 'elems' => [ + bless +( { + + 'struct' => [...], + + 'elems' => [ + + { + + 'attrs' => [], + + 'elems' => [ + + bless( { + + 'struct' => [...], + + 'elems' => [ + + {...}, + + {...} + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + + ], + + ... + + } + + ], + + 'tag' => 'sequence' + + }, 'BLOCK' ) + ], + ... + } + ], + 'tag' => 'sequence' + }, 'BLOCK' ) + ], + ... + } + ], ' +tag' => 'sequence' }, +'BLOCK' ) ], ... }, { 'attrs' => [], 'elems' => [ bless( { ' +struct' => [...], ' +elems' => [ + { + 'attrs' => [], + 'elems' => [ + bless( { + 'struct' => [...], + 'elems' => [ + {...}, + {...}, + {...}, + {...} + ], + 'tag' => 'sequence' + }, 'BLOCK' ) + ], + ... + } + ], ' +tag' => 'sequence' }, +'BLOCK' ) ], ... } ], 'tag' => 'sequence' }, 'BLOCK' ) ], ... };
UPDATED: original post was cut off for being too long. Abbreviated LOG output.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Nested Bless within Hash of Arrays
by chromatic (Archbishop) on Jul 22, 2013 at 21:31 UTC | |
by ksublondie (Friar) on Jul 22, 2013 at 22:05 UTC | |
by chromatic (Archbishop) on Jul 23, 2013 at 00:08 UTC | |
Re: Nested Bless within Hash of Arrays
by Loops (Curate) on Jul 22, 2013 at 20:46 UTC | |
by ksublondie (Friar) on Jul 22, 2013 at 21:14 UTC | |
by ksublondie (Friar) on Jul 22, 2013 at 20:58 UTC | |
by ksublondie (Friar) on Jul 22, 2013 at 21:28 UTC | |
Re: Nested Bless within Hash of Arrays
by hdb (Monsignor) on Jul 23, 2013 at 07:17 UTC | |
by ksublondie (Friar) on Jul 23, 2013 at 15:49 UTC | |
by hdb (Monsignor) on Jul 23, 2013 at 15:51 UTC |
Back to
Seekers of Perl Wisdom