no default value support in xmerl?

Joakim G. jocke@REDACTED
Mon Mar 14 07:54:09 CET 2011


The XML schema support in xmerl considers all default elements
as mandatory.

If this is true it is a bug of a grander scale.

================================================================
Take for example test.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="foo">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="bar" type="xs:string" default="bingo"/>
        <xs:element name="baz" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

================================================================
and test.xml:

<foo>
  <baz>42</baz>
</foo>

================================================================
then you will see:

28> xmerl_scan:file("/tmp/test.xml", [{validation, schema},
{schemaLocation, [{"foo", "/tmp/test.xsd"}]}]).
3940- fatal: {failed_schema_validation,
                 [{[],xmerl_xsd,
                   {missing_mandatory_elements,
                       {element,{{bar,[anonymous,foo],[]},{1,1}}}}}]}
** exception exit: {fatal,
                       {{failed_schema_validation,
                            [{[],xmerl_xsd,
                              {missing_mandatory_elements,
                                  {element,
                                      {{bar,[anonymous,foo],[]},{1,1}}}}}]},
                        {file,"/tmp/test.xml"},
                        {line,4},
                        {col,1}}}
     in function  xmerl_scan:fatal/2
     in call from xmerl_scan:scan_document/2
     in call from xmerl_scan:file/2
29>

================================================================

Default values are not mandatory AFAIK. I might be doing
something wrong. It has happened before.

Cheers
/Jocke


More information about the erlang-questions mailing list