[xsd-users] XSD 3.3.0 possible error when using type xsd:hexBinary with default value

Meng, Emil emeng at qualcomm.com
Fri Jul 20 01:48:41 EDT 2012


Hi,

We have been trying to use xsd 3.3.0 and have run into some issues with our schema where 3.2.0 works without problems. After debugging the issue, we found what seems to be an error in the code generated in 3.3.0 under certain conditions. So far, we see the problem when the following conditions are true:

1. An element where Restrictions/enums are used, and there are greater than 9 entries
2. An element contains type xsd:hexBinary, and a default value exists (we're using 01ffff, unknown if other values cause the problem, but without a default value, things work fine)

What happens is that the generated code has a literal value that is written in hex but without the '0x' prefix. This causes the compiler to not be able to differentiate a 'b' from a variable or a the decimal value 11. An example error case can be seen:

../../../../bin/xsd cxx-tree  hello.xsd
g++ -I../../../../libxsd -W -Wall -O3 -c driver.cxx -o driver.o
g++ -I../../../../libxsd -W -Wall -O3 -c hello.cxx -o hello.o
hello.cxx: In member function 'name::value name::_xsd_name_convert() const':
hello.cxx:400: error: 'a' was not declared in this scope
hello.cxx: At global scope:
hello.cxx:413: error: 'a' was not declared in this scope
hello.cxx:428: error: 'a' was not declared in this scope
make: *** [hello.o] Error 1

We have taken the hello example and modified the hello.xsd file to exhibit the problem stated above. Below is the pasted schema (not sure how the mailing list handles attachments, so just pasting the file in... feel free to request an attachment and I will send it). In the example the enum "deadbabe" is the 10th element causing the generated code to have a literal 'a' instead of '0xa' or '10'.

Any help in figuring this out would be greatly appreciated!

Thanks,
-emil

hello.xsd

<?xml version="1.0"?>

<!--

file      : examples/cxx/tree/hello/hello.xsd
author    : Boris Kolpackov <boris at codesynthesis.com>
copyright : not copyrighted - public domain

-->

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:complexType name="resource_alloc_type0">
        <xsd:annotation>
            <xsd:documentation>no doc</xsd:documentation>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="thiskillsme" type="xsd:hexBinary" default="01FFFF">
                <xsd:annotation>
                    <xsd:documentation>no doc</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

  <xsd:complexType name="hello_t">

    <xsd:annotation>
      <xsd:documentation>
        The hello_t type consists of a greeting phrase and a
        collection of names to which this greeting applies.
      </xsd:documentation>
    </xsd:annotation>

    <xsd:sequence>

      <xsd:element name="greeting" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>
            The greeting element contains the greeting phrase
            for this hello object.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>

      <xsd:element name="name" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>
            The name elements contains names to be greeted.
          </xsd:documentation>
        </xsd:annotation>
       <xsd:simpleType>
          <xsd:restriction base="xsd:string">
            <xsd:enumeration value="world"/>
            <xsd:enumeration value="moon"/>
            <xsd:enumeration value="sun"/>
            <xsd:enumeration value="asdf"/>
            <xsd:enumeration value="fdsa"/>
            <xsd:enumeration value="foo"/>
            <xsd:enumeration value="bar"/>
            <xsd:enumeration value="borf"/>
            <xsd:enumeration value="barf"/>
            <xsd:enumeration value="deadbabe"/>
          </xsd:restriction>
        </xsd:simpleType>
      </xsd:element>

    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="hello" type="hello_t">
    <xsd:annotation>
      <xsd:documentation>
        The hello element is a root of the Hello XML vocabulary.
        Every conforming document should start with this element.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

</xsd:schema>


More information about the xsd-users mailing list