[Xml-compile] Error compiling schema for element with a default and an attribute

Philip Garrett philgarr at gmail.com
Mon Mar 12 16:59:20 GMT 2012


Hi list,

I have a schema that I would like to compile using XML::Compile::Schema, but I am getting an error when I try to create a reader:

  $ xml2yaml -s gender.xsd -x test.xml 
  Can't locate object method "node" via package "U" (perhaps you forgot to load "U"?) at /opt/local/lib/perl5/site_perl/5.12.3/XML/Compile/Translate/Reader.pm line 647.

Where "U" is the default value for the element.  I *am* able to compile a writer, and reader also works when I set default_values to IGNORE. The problem does occur when default_values is either EXTEND or MINIMAL.  I have pruned the schema and example xml to the minimum necessary to reproduce the problem. The files are below.

Is the combination of defaults with complexType/simpleContent expected to work?

TIA,
Philip

----
<!-- gender.xsd -->
<xs:schema
 targetNamespace="http://example.com/xml-compile-default/gender"
 xmlns="http://example.com/xml-compile-default/gender"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:element name="gender" default="U">
 <xs:complexType>
  <xs:simpleContent>
   <xs:extension base="xs:string">
    <xs:attribute name="nid" use="required" />
   </xs:extension>
  </xs:simpleContent>
 </xs:complexType>
</xs:element>
</xs:schema>]
----
<!-- test.xml -->
<gender
 xmlns="http://example.com/xml-compile-default/gender"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://example.com/xml-compile-default/gender gender.xsd"
 nid="abc">F</gender>
----



More information about the Xml-compile mailing list