[Xml-compile] Schema reader doesn't compile but schema writer
	does?
    Mark Overmeer 
    mark at overmeer.net
       
    Tue Sep  3 11:41:22 GMT 2013
    
    
  
Hi Ciaran,
* DEIGNAN Ciaran (C.DEIGNAN at rsd.com) [130903 09:36]:
> The application can supply the schema for the data it provides. I can
> create a writer from a schema, but I can't always create a reader.
> I get the following error, and I don't know if the problem is in the
> schema or in XML::Compile:
> 
> <xs:element default="false" minOccurs="0" name="vital" nillable="true"
>   type="xs:boolean">
> 
> Perhaps it's strange to have a default on an element that's nillable...?
I think it is a bug in XML::Compile.  It has to do with the preparation
to return the default value.  The defaults need to follow the rules of
their main type here (boolean), so at compile-time they get sent through
the same routines as the processing of the element will walk later.
Can you please test if this patch is sufficient:
lib/XML/Compile/Translate/Reader.pm line 698:
 sub makeSimpleElement
 {  my ( $self, $path, $tag, $st, undef, undef, $comptype, $is_nillable) = @_;
      $is_nillable
    ? sub { my $tree  = shift or return $st->(undef);
 -          my $value = $tree->nodeNil ? 'NIL' : $st->($tree);
 +          my $value = ref $tree && $tree->nodeNil ? 'NIL' : $st->($tree);
            defined $value ? ($tag => $value) : ();
          }
-- 
Regards,
               MarkOv
------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net
    
    
More information about the Xml-compile
mailing list