Re: Extension of xs:simpleContent

"Pete Cordell" <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <BD0EDD804F0643E2B6AD21DDBC2E2505@Codalogic>
Hi Mukul,

Thanks for trying it on Xerces.  It's a validator I don't have.

Motivated by your suggestion I decided to look for an on-line version and 
found the following:

http://validate.openlaboratory.net/

I put in the following files:

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

    <xs:complexType name="DoubleBase">
        <xs:simpleContent>
            <xs:extension base="xs:double">
                <xs:attribute name="DoubleBaseAttr" type="xs:boolean"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="DoubleBaseExtension">
      <xs:complexContent>
            <xs:extension base="DoubleBase">
                <xs:attribute name="DoubleExtensionAttr" type="xs:boolean"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:element name="DoubleElement" type="DoubleBaseExtension"/>

</xs:schema>

----Fail.xml-----
<DoubleElement DoubleExtensionAttr="true" 
DoubleBaseAttr="false">1.5</DoubleElement>

While it reported that the XSD and XML were OK, it displayed the following 
error message.

======
Validation results

Checking first import/include references in schema files:
Fail.xsd: OK
Fail.xml: OK

Running validation process '/usr/bin/DOMPrint'

Errors detected:
Error at file "Fail.xml", line 2, column 69
   Message: No character data is allowed by content model

Instance Fail.xml:
<?xml version="1.0" encoding="UTF-8"?>
<DoubleElement DoubleExtensionAttr="true" 
DoubleBaseAttr="false">1.5</DoubleElement>

======

Does anybody know what an instance should look like if the schema is OK, but 
this instance is wrong?

BTW: I don't know what version of Xerces the page uses.

Thanks,

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info
----- Original Message ----- 
From: "Mukul Gandhi" <[email protected]>
To: "Pete Cordell" <[email protected]>
Cc: <[email protected]>
Sent: Wednesday, November 17, 2010 5:50 PM
Subject: Re: Extension of xs:simpleContent



Hi Pete,
   I believe the schema you've posted is correct (I cross checked with
Xerces too). I think for simpleContent instances, schema component
complexContent can be used technically as well (since simpleContent is
a subset of complexContent).

Though I would have designed the schema type "DoubleBaseExtension"
specified in your example, to use simpleContent rather than
complexContent (as you rightly said too).

On Wed, Nov 17, 2010 at 10:45 PM, Pete Cordell <[email protected]> 
wrote:
> I have a customer who has a schema that extends a simple type double into 
> a
> complex type with simple content, and then as a separate construct extends
> that into a complex type with complex content. They do this along the
> following lines:
>
> <xs:complexType name="DoubleBase">
> <xs:simpleContent>
> <xs:extension base="xs:double">
> <xs:attribute name="DoubleBaseAttr" type="xs:boolean"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
> <xs:complexType name="DoubleBaseExtension">
> <xs:complexContent>
> <xs:extension base="DoubleBase">
> <xs:attribute name="DoubleExtensionAttr" type="xs:boolean"/>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> (To avoid confusion, the intent of the latter is to add the
> DoubleExtensionAttr attribute rather than mandate that you've got
> complexContent.)
>
> My feeling is this is wrong because DoubleBaseExtension should specify
> xs:simpleContent rather than xs:complexContent.
>
> However, XML Spy and Visual Studio seem to accept the above, and the 
> example
> is actually based on a industry consortium schema that specifies similar
> constructs.
>
> So my questions are:
>
> 1) Is the above schema correct or not?
>
> 2) If it is technically incorrect, is it widely occurring (possibly 
> because
> tools fail to pick it up) and therefore worth overlooking this error?
>
> Thanks,
>
> Pete Cordell
> Codalogic Ltd
> Interface XML to C++ the easy way using C++ XML
> data binding to convert XSD schemas to C++ classes.
> Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
> for more info





-- 
Regards,
Mukul Gandhi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.