Author |
Message
|
Seb |
Posted: Tue Oct 20, 2009 4:47 am Post subject: XML Schema restrictions in the message model |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 20, 2009 4:53 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
|
Back to top |
|
 |
Seb |
Posted: Tue Oct 20, 2009 5:32 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
Hi,
thanks for the links, would be interesting to know, if these are the only restrictions.
Actually I am having problems with an XML Schema I got from a customer.
That one is a simpler version that creates the same error, when I create a Message Definition from it.
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://www.company.de/schemas" targetNamespace="http://www.company.de/schemas">
<xsd:element name="MyRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MyElement" minOccurs="0">
<xsd:complexType>
<xsd:simpleContent>
<xsd:restriction base="MyType">
<xsd:totalDigits value="15"/>
<xsd:attribute name="MyAttribute">
<xsd:simpleType>
<xsd:restriction base="xsd:boolean">
<xsd:pattern value="(true|false)"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="MyType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:anyAttribute namespace="##any"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>
|
I get the following error:
Quote: |
Type restriction error 'http://www.company.de/schemas#MyElement_._type' (content type incompatible with the content type of the baseType): attribute declaration 'MyAttribute' does not exist in the base type. |
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 20, 2009 5:45 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Does the XSD validate otherwise, before you create an message definition from it? |
|
Back to top |
|
 |
Seb |
Posted: Tue Oct 20, 2009 6:06 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
Yes, it does
Schema validating with XSV 3.1-1 of 2007/12/11 16:20:05
* Target: file:/usr/local/XSV/xsvlog/tmpVSvBrTuploaded
(Real name: MyTest.xsd)
* docElt: {http://www.w3.org/2001/XMLSchema}schema
* Validation was strict, starting with type [Anonymous]
* The schema(s) used for schema-validation had
no errors
* No schema-validity problems were found in the target
It seems the problem within the schema is the anyAttribute definition. If I define the attribute explicitly, it works. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 20, 2009 2:22 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Never mind what XSV claims, your schema looks broken to me:
Code: |
...
<xsd:element name="MyElement" minOccurs="0">
<xsd:complexType>
<xsd:simpleContent>
<xsd:restriction base="MyType">
...
<xsd:complexType name="MyType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:anyAttribute namespace="##any"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
|
'MyType' is a complex type with simple content.
The type of myElement is a complex type with simple content, and the base type of that simple content is complex type 'MyType'. That's wrong - you cannot define simple content as a restriction of a complex type. |
|
Back to top |
|
 |
Seb |
Posted: Wed Oct 21, 2009 12:18 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
Hi Kimbert,
thanks for your comment.
I changed the definition within "MyElement" to <xsd:complexContent>, but the error in the Toolkit after creating the MsgDef stays the same. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Oct 21, 2009 1:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What happens if you remove the pattern value of the boolean.
If you wish to define a boolean with pattern value restriction you need to describe a complex type that extends the boolean and not a boolean. (IMHO)
Standard boolean can have 0,1,true,false as values. _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Wed Oct 21, 2009 1:30 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Having taken another look, this schema appears to be restricting ( or trying to ) the xs:integer in MyType with some simple content based on xs:boolean
My suggestion: go back to the author and ask
a) how they authored this schema
b) what their requirements are
Once you have that info, you ( or they ) stand a chance of creating a valid schema that does what is required. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Oct 21, 2009 1:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
They define a complex type, extending MyType by adding an attribute like this
Quote: |
<xsd:attribute name="MyAttribute">
<xsd:simpleType>
<xsd:restriction base="xsd:boolean">
<xsd:pattern value="(true|false)"/>
</xsd:restriction> |
I believe that the attribute should be typed as a complex type and not a simpleType as it carries restrictions to the simple type boolean.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Wed Oct 21, 2009 2:36 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
My last comment was incorrect. I was mis-reading the schema ( I thought the xs:boolean restriction was defining the simple content of MyElement ).
Quote: |
I believe that the attribute should be typed as a complex type and not a simpleType |
Nope - attributes can only have simple types. |
|
Back to top |
|
 |
Seb |
Posted: Wed Oct 21, 2009 2:48 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
Hi guys,
as Kimbert adviced, I will try to get back to the authors. Not the easiest way, as it is another company (our service provider) and the communication takes up a number of instances.
It seems they introduced the attribute to somehow delete the element when it is processed but not necessary. I think there are better ways of doing that. Thus, I have to find out and understand the functional requirement for this attribute.
Thanks for your help so far. |
|
Back to top |
|
 |
Seb |
Posted: Wed Oct 21, 2009 3:54 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
Just for my interest ... if it comes to a discussion.
I made it even simpler and asking what is still wrong with the schema. I define a base complex type that could have virtually any attribute. Within my element I use that complex type and restrict the number of attributes to only one of type integer.
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://www.company.de/schemas" targetNamespace="http://www.company.de/schemas">
<xsd:element name="MyElement">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="MyType">
<xsd:attribute name="MyAttribute" type="xsd:integer"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="MyType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:anyAttribute namespace="##any"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>
|
|
|
Back to top |
|
 |
kimbert |
Posted: Thu Oct 22, 2009 2:52 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I can't see anything wrong with that schema. What error are you getting? |
|
Back to top |
|
 |
Seb |
Posted: Thu Oct 22, 2009 3:00 am Post subject: |
|
|
Apprentice
Joined: 27 Mar 2009 Posts: 41
|
Hi Kimbert,
This is the error I get:
Quote: |
Type restriction error 'http://www.company.de/schemas#MyElement_._type' (content type incompatible with the content type of the baseType): attribute declaration 'MyAttribute' does not exist in the base type. |
|
|
Back to top |
|
 |
|