[Xml-compile] repeat tags with XML::Schema

Hugues Max huguesmax at gmail.com
Tue Jun 25 11:06:57 GMT 2013


"Alors la chapeau..."
thanks very much it's working

One question
in
push @pmtids, + {PmtId => {
what mean this +

normal push is

push(@pmtids, $value);

and what is the sens of \@ instead of @ in  ( this is a ref to.. ?)

$s->{CstmrDrctDbtInitn}{PmtInf}{DrctDbtTxInf} = \@pmtids;





Le 25/06/2013 12:36, Mark Overmeer a écrit :
> * Hugues Max (huguesmax at gmail.com) [130625 09:21]:
>> I use XML::Compile::Schema
>> my $schema = XML::Compile::Schema->new('./2.xsd');
>>
>> my $write = $schema->compile(WRITER =>
>> '{urn:iso:std:iso:20022:tech:xsd:2}Document', use_default_namespace
>> => 1, include_namespaces => 1);
> You can better start with the ::Cache:
>
>    my $schema = XML::Compile::Cache->new('./2.xsd'
>     , prefixes => [ '' => 'urn:iso:std:iso:20022:tech:xsd:2' ]
>     );
>
>    my $write  = $schema->compile(WRITER => 'Document');
>
>> $s->{CstmrDrctDbtInitn}->{PmtInf}->{DrctDbtTxInf}->{PmtId}->{InstrId} = $a;
>> $s->{CstmrDrctDbtInitn}->{PmtInf}->{DrctDbtTxInf}->{PmtId}->{EndToEndId}
>> = $b;
> I would advice:
>
>     my $pmtid = $s->{CstmrDrctDbtInitn}{PmtInf}{DrctDbtTxInf}{PmtId} ||= {};
>     $pmtid->{InstrId}    = $a;
>     $pmtid->{EndToEndId} = $b;
>
>     my $pmtid = $s->{CstmrDrctDbtInitn}{PmtInf}{DrctDbtTxInf}{PmtId}
>               = +{ InstrId => $a, EndToEndId => $b };
>
>> If I do that, in my xml file there are only $c and $d
>> If I create manually $s using [..] it'working
>>
>> my $s = CstmrDrctDbtInitn => {  PmtInf => { DrctDbtTxInf =>
>> [
>> {PmtId     => { InstrId => '1', EndToEndId =>'ref1'}},
>> {PmtId     => { InstrId => '2', EndToEndId =>'ref2'}}
>> ]}};
>    my @pmtids;
>    push @pmtids, +{ PmtId => {InstrId => 1, EndToEndId =>'ref1'}};
>    push @pmtids, +{ PmtId => {InstrId => 2, EndToEndId =>'ref2'}};
>
>    $s->{CstmrDrctDbtInitn}{PmtInf}{DrctDbtTxInf} = \@pmtid;




More information about the Xml-compile mailing list