* Hugues Max ([email protected]) [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;
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net


_______________________________________________
Xml-compile mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile

Reply via email to