The second issue is https://issues.apache.org/jira/browse/XERCESC-1937 that was recently fixed; the workaround is to place the xsi:type *after* the xsi:schemaLocation attribute. For the first one, it is probably a bug: the specs define xsi:type as a QName, and QName have a whitespace property of "collapse" that should convert tabs and line feeds into spaces before trimming. Can you create a JIRA issue for this one?

Thanks,
Alberto

On 9/24/2010 5:11 PM, Oppmann, Herbert wrote:
Hi,

I noticed that Xerces-C 3.1.1 does not validate things that Altova XMLSpy 2011 
and the XML Parser of the .NET Framework 2.0 do validate. Reading the W3C 
standards, I fear that Xerces-C is not fully standards conform, but I want to 
have some others have a look at it before I file a JIRA issue.


First issue: Whitespace in xsi:type
===================================
Adding space characters to the front or end of type names is accepted by 
Xerces. But adding other whitespace chars (TAB, CR, LF) is not accepted:

Error at file D:\Out\Xerces\WhitespaceInXsiType/test.xml, line 3, char 54
   Message: type '? UIntegerT' specified in 'xsi:type' cannot be resolved

Error at file D:\Out\Xerces\WhitespaceInXsiType/test.xml, line 3, char 54
   Message: attribute 'bitLength' is not declared for element 'Datatype'


Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.example.com/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://www.example.com/"; elementFormDefault="qualified" 
attributeFormDefault="unqualified">
        <xsd:element name="Variable">
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element name="Datatype" type="DatatypeT"/>
                        </xsd:sequence>
                </xsd:complexType>
        </xsd:element>
        <xsd:complexType name="DatatypeT" abstract="true">
                <xsd:attribute name="id" type="xsd:token"/>
        </xsd:complexType>
        <xsd:complexType name="UIntegerT">
                <xsd:complexContent>
                        <xsd:extension base="DatatypeT">
                                <xsd:attribute name="bitLength" type="xsd:unsignedInt" 
use="required"/>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:complexType name="OctetStringT">
                <xsd:complexContent>
                        <xsd:extension base="DatatypeT">
                                <xsd:attribute name="fixedLength" type="xsd:unsignedInt" 
use="required"/>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
</xsd:schema>

Instance:

<?xml version="1.0" encoding="UTF-8"?>
<Variable xmlns="http://www.example.com/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.example.com/ 
Test.xsd">
        <Datatype xsi:type="&#10;UIntegerT" bitLength="12"/>
</Variable>


Second issue: xsi:type does not seem work in the main element
=============================================================
Xerces complains:

Error at file D:\Out\Xerces\XsiTypeInMainElement/test.xml, line 2, char 188
   Message: type of element 'Datatype' is abstract; use 'xsi:type' to specify 
non
-abstract type instead

Error at file D:\Out\Xerces\XsiTypeInMainElement/test.xml, line 2, char 188
   Message: attribute 'bitLength' is not declared for element 'Datatype'


Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.example.com/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://www.example.com/"; elementFormDefault="qualified" 
attributeFormDefault="unqualified">
        <xsd:element name="Datatype" type="DatatypeT"/>
        <xsd:complexType name="DatatypeT" abstract="true">
                <xsd:attribute name="id" type="xsd:token"/>
        </xsd:complexType>
        <xsd:complexType name="UIntegerT">
                <xsd:complexContent>
                        <xsd:extension base="DatatypeT">
                                <xsd:attribute name="bitLength" type="xsd:unsignedInt" 
use="required"/>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:complexType name="OctetStringT">
                <xsd:complexContent>
                        <xsd:extension base="DatatypeT">
                                <xsd:attribute name="fixedLength" type="xsd:unsignedInt" 
use="required"/>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
</xsd:schema>

Instance:

<?xml version="1.0" encoding="UTF-8"?>
<Datatype xsi:type="UIntegerT" bitLength="12" xmlns="http://www.example.com/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.example.com/ Test.xsd"/>



With best regards,
Herbert Oppmann

Siemens AG
Industry Sector
Industry Automation Division
Industrial Automation Systems
Research&  Development
I IA AS R&D DH N 3
Gleiwitzer Str. 555
90475 Nuremberg, Germany
Tel.: +49 (911) 895-2657
Fax: +49 (911) 895-152657
mailto:[email protected]

Siemens Aktiengesellschaft: Chairman of the Supervisory Board: Gerhard Cromme; 
Managing Board: Peter Loescher, Chairman, President and Chief Executive 
Officer; Wolfgang Dehen, Brigitte Ederer, Heinrich Hiesinger, Joe Kaeser, 
Barbara Kux, Hermann Requardt, Siegfried Russwurm, Peter Y. Solmssen; 
Registered offices: Berlin and Munich, Germany; Commercial registries: Berlin 
Charlottenburg, HRB 12300, Munich, HRB 6684; WEEE-Reg.-No. DE 23691322.


Reply via email to