W3C home > Mailing lists > Public > www-ws-desc@w3.org > July 2005

Re: Whoops - Example is invalid upate attached

From: RDBMS <RDBMS@aol.com>
Date: Thu, 21 Jul 2005 10:08:08 -0700
Message-ID: <001601c58e16$c7690360$6701a8c0@phnx.qwest.net>
To: "Booth, David \(HP Software - Boston\)" <dbooth@hp.com>
Cc: "Arthur Ryman" <ryman@ca.ibm.com>, <www-ws-desc@w3.org>, <kevin.liu@sap.com>

Hi David,

Thanks again to you and Arthur for your patience in this matter.

I agree. Some additional examples (both valid/invalid), and clarification
around namespace inheritance would be great ! It would help to avoid having
others pester you at length because they also misinterpreted  ;-)

J. Bean
P.O. Box 30171
Phoenix, AZ  85046-0171

RDBMS@aol.com
XML-Guy@hotmail.com
----- Original Message ----- 
From: "Booth, David (HP Software - Boston)" <dbooth@hp.com>
To: "RDBMS" <RDBMS@aol.com>
Cc: "Arthur Ryman" <ryman@ca.ibm.com>; <www-ws-desc@w3.org>;
<kevin.liu@sap.com>
Sent: Thursday, July 21, 2005 9:20 AM
Subject: RE: Whoops - Example is invalid upate attached


James,

I think we've finally isolated the misunderstanding.  In your examples,
SchemaA is *indirectly* making use of something that was defined in
SchemaC.  SchemaA is not directly referencing any names from SchemaC.
That is the key difference.  The need for the xs:import statement
applies to the *direct* use of names from another namespace.  You do NOT
need to use xs:import if SchemaA does not *directly* reference a name
from SchemaC, even though SchemaA uses something defined in SchemaB and
SchemaB in turn uses something defined in SchemaC.

In other words, xs:import only affects the lexical visibility of
components -- not their existence or functionality.

This is admittedly a confusing aspect of XML Schema, because it means
that components from another namespace can exist without being
referenceable (unless they are xs:imported).  The behavior of WSDL 2.0
is intended to be exactly the same as in XML Schema in this regard.

Here is a new set of simplified examples, showing an invalid example and
two different ways to correct it.  Do these help to clarify the
misunderstanding?  If so, I think it would be helpful to include them
either in the spec or in the primer, in addition to whatever
clarifications are incorporated.

-------------- InvalidSchemaA.xsd --------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  targetNamespace="http://example.com/A"
  xmlns="http://example.com/A"
  xmlns:B="http://example.com/B"
  xmlns:C="http://example.com/C">

<!--  Note that only http://example.com/B is imported.
      http://example.com/C is NOT imported.  -->
<xs:import namespace="http://example.com/B"
  schemaLocation="SchemaB.xsd"/>

<!--  The complexType below attempts to reference a name from the
      http://example.com/C namespace, which was NOT imported,
      therefore this reference is INVALID.  -->
<xs:element name="ElementA">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="C:ElementC" minOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

</xs:schema>

-------------- ValidSchemaA1.xsd --------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  targetNamespace="http://example.com/A"
  xmlns="http://example.com/A"
  xmlns:B="http://example.com/B"
  xmlns:C="http://example.com/C">

<!--  This example corrects InvalidSchemaA.xsd by importing
      http://example.com/C, thus making C:ElementC directly
      referenceable from within ValidSchemaA1.xsd.  -->
<xs:import namespace="http://example.com/B"
  schemaLocation="SchemaB.xsd"/>
<xs:import namespace="http://example.com/C"
  schemaLocation="SchemaC.xsd"/>

<!--  ElementA1 successfully references C:ElementC.  -->
<xs:element name="ElementA1">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="C:ElementC" minOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

</xs:schema>


-------------- ValidSchemaA2.xsd --------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  targetNamespace="http://example.com/A"
  xmlns="http://example.com/A"
  xmlns:B="http://example.com/B"
  xmlns:C="http://example.com/C">

<!--  This example uses a different approach to correct
      InvalidSchemaA.xsd, by eliminating the direct reference
      to C:ElementC.  Note that only http://example.com/B
      is imported.  http://example.com/C is NOT imported.  -->
<xs:import namespace="http://example.com/B"
  schemaLocation="SchemaB.xsd"/>

<!--  ElementA references B:ElementB.  Note that
      it does not directly reference C:ElementC, therefore
      it is valid.  The fact that C:ElementC can be referenced
      from within SchemaB.xsd is irrelevant to the question of
      whether it can be referenceable from here.  -->
<xs:element name="ElementA2">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="B:ElementB" minOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

</xs:schema>


------------------------ SchemaB.xsd -------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           targetNamespace="http://example.com/B"
           xmlns="http://example.com/B"
           xmlns:C="http://example.com/C">

   <!--  SchemaB.xsd imports http://example.com/C so that
         it can reference C:ElementC.  -->
   <xs:import namespace="http://example.com/C"
      schemaLocation="SchemaC.xsd"/>

   <!--  B:ElementB references C:ElementC  -->
   <xs:element name="ElementB">
       <xs:complexType>
           <xs:sequence>
               <xs:element ref="C:ElementC"/>
           </xs:sequence>
       </xs:complexType>
   </xs:element>

</xs:schema>

----------------------- SchemaC.xsd -----------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           targetNamespace="http://example.com/C"
           xmlns="http://example.com/C">

   <!--  Definition of C:ElementC  -->
   <xs:element name="ElementC" type="TypeT"/>

   <xs:simpleType name="TypeT">
       <xs:restriction base="xs:integer">
       <xs:enumeration value="1"/>
       <xs:enumeration value="2"/>
       </xs:restriction>
   </xs:simpleType>

</xs:schema>

========================================================================

David Booth


-----Original Message-----
From: Arthur Ryman [mailto:ryman@ca.ibm.com]
Sent: Wednesday, July 20, 2005 6:12 PM
To: RDBMS; www-ws-desc@w3.org
Cc: Booth, David (HP Software - Boston)
Subject: Re: Whoops - Example is invalid upate attached



James,

Thx for the example.

You are misinterpretting the spec. Your WSDL only references one
namespace, http://www.testA.com:

        <message name="GetElementA">
                <part name="body" element="A:RootElementFromA" />
        </message>

Therefore you only need to import namespace A:

        <xs:import namespace="http://www.testA.com"
schemaLocation="SchemaA.xsd"/>

The fact that the element A:RootElementFromA references B and C is
irrelevant. The WSDL just references namespace http://www.testA.com so
that's all you need to import.

Arthur Ryman,
Rational Desktop Tools Development

phone: +1-905-413-3077, TL 969-3077
assistant: +1-905-413-2411, TL 969-2411
fax: +1-905-413-4920, TL 969-4920
mobile: +1-416-939-5063, text: 4169395063@fido.ca
intranet: http://labweb.torolab.ibm.com/DRY6/


"RDBMS" <RDBMS@aol.com>
07/20/2005 04:51 PM Please respond to
"RDBMS"

To"Booth, David \(HP Software - Boston\)" <dbooth@hp.com>
ccArthur Ryman/Toronto/IBM@IBMCA
SubjectRe: Whoops - Example is invalid  upate attached







Hi David, Arthur,

I thought that I would give it one more try ;-)

Attached are two examples (although WSDL 1.0/1.1 - sorry). Not elegant,
but
something I could throw together quickly.

The WSDL with name terminating in "1" is what I would like to do with
WSDL
2.0.  Note that in the <types/>, I import a single top-level schema for
SchemaA.xsd.

I do not declare additional imports for SchemaB.xsd or SchemaC.xsd. They
are
already declared intrinsic to my schema hierarchy.

Note that I reference the entire message context of SchemaA in my WSDL
and
generate a corresponding SOAP request, even though much of that context
is
derived through the schema hierarchy (xs:import of SchemaB and SchemaC).

This is slightly different than David has asked for, but reflects a
scenario
I run into often. Think of it as an over-simplified "doc/literal"
example
;-)

The WSDL with the name terminating in "2" is what I have interpreted
that I
must do with WSDL 2.0.  I must redeclare xs:imports for schemas B and C,
because according to the text from the draft, the subordinate xs:imports
in
my schema hierarchy are "not available to WSDL".

If this is the case, it is not just a simple duplicate declaration.  I
also
have to navigate my schema hierarchy to determine what all those nested
imports might be, expose my schema structure to WSDL - even though it is
already defined by my schema hierarchy, and I now statically define a
second
representation of the hierarchy. If something in that schema hierarchy
changes later, I have to duplicate the maintenance effort.

Does this help ?

Thanks again !

J. Bean
P.O. Box 30171
Phoenix, AZ  85046-0171

RDBMS@aol.com
XML-Guy@hotmail.com
----- Original Message ----- 
From: "Booth, David (HP Software - Boston)" <dbooth@hp.com>
To: "RDBMS" <RDBMS@aol.com>
Cc: "Arthur Ryman" <ryman@ca.ibm.com>
Sent: Wednesday, July 20, 2005 11:20 AM
Subject: RE: Whoops - Example is invalid upate attached


James,

Your latest example still lacks a direct reference from something in
targetNamespace http://www.testA.com to something that was defined in
targetNamespace http://www.testC.com.  It only directly references
something that was defined in targetNamespace http://www.testB.com.

Try the following modification of your example instead.  Note that the
definition of RootElement2FromA attempts to reference C:ElementFromC,
though the C namespace was not xs:imported.


-------------- SchemaA.xsd --------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified"
  targetNamespace="http://www.testA.com"
  xmlns="http://www.testA.com"
  xmlns:B="http://www.testB.com"
  xmlns:C="http://www.testC.com">

<!--  Note that the import below ONLY imports schema "B". Schema "C"
isimported by declaration from wityhin schema "B", so you will not see
ithere  -->
<xs:import namespace="http://www.testB.com"
schemaLocation="SchemaB.xsd"/>

<!--  The complexType below references a global declaration that
isdefined in schema B  -->
<xs:element name="RootElementFromA">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="B:ElementFromB" minOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

<!--  The complexType below attempts to reference a global
declarationthat is defined in schema C.  However, the targetNamespace
for C,http://www.testC.com , was not xs:imported.  -->
<xs:element name="RootElement2FromA">
 <xs:complexType>
  <xs:sequence>
   <xs:element ref="C:ElementFromC" minOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>
</xs:schema>

------------------------ SchemaB.xsd -------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           targetNamespace="http://www.testB.com"
           xmlns="http://www.testB.com"
           xmlns:C="http://www.testC.com">

   <!--  Note that the import below ONLY imports schema "C". Schema"C"
is not declared or defined as an xs:import to the top-level
schemaSchemaA  -->
   <xs:import namespace="http://www.testC.com"
schemaLocation="SchemaC.xsd"/>

   <!--  Note that the element below "declares" a global element.It is
"referenced" from SchemaA  -->
   <xs:element name="ElementFromB">
       <xs:complexType>
           <xs:sequence>
               <xs:element ref="ElementFromB-2"/>
               <xs:element ref="C:ElementFromC"/>
           </xs:sequence>
       </xs:complexType>
   </xs:element>

   <xs:element name="ElementFromB-2"/>

</xs:schema>

----------------------- SchemaC.xsd -----------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           targetNamespace="http://www.testC.com"
           xmlns="http://www.testC.com">

   <!--  Note that the element below "declares" a global element.It is
"referenced" from SchemaB, and by inheritance/import will be inthe
instance as part of A  -->
   <xs:element name="ElementFromC" type="TypeT"/>

   <xs:simpleType name="TypeT">
       <xs:restriction base="xs:integer">
       <xs:enumeration value="1"/>
       <xs:enumeration value="2"/>
       </xs:restriction>
   </xs:simpleType>

</xs:schema>


-----Original Message-----
From: RDBMS [mailto:RDBMS@aol.com]
Sent: Wednesday, July 20, 2005 8:14 AM
To: Arthur Ryman
Cc: Booth, David (HP Software - Boston)
Subject: Re: Whoops - Example is invalid upate attached


Hi Arthur, David,

Here is another example that might be better. It validates with msxml4
and with XML Spy.

In this case, the hierarchy is A -> B -> C

The instance document will represent structure and containers that are
declared from all 3 schemas.

Yet, SchemaA (top-level) only imports SchemaB.  It does not import
SchemaC.

SchemaB imports SchemaC.

Sorry about the validation error (again). Proves that haste can cause
problems ;-)

Although very simple and a single branch, this example is more
representative of the schema reuse and assembly scenario I run into
quite a lot. You could extend this simple model horizontally and
vertically with additional imports.

Also, and if I am still interpreting the WSDL draft correctly, it
requires that I have to declare imports for all 3 schemas in <types/>,
rather than just SchemaA.

Thanks again,
J. Bean
P.O. Box 30171
Phoenix, AZ  85046-0171

RDBMS@aol.com
XML-Guy@hotmail.com
----- Original Message ----- 
From: Arthur Ryman
To: RDBMS
Cc: Booth, David (HP Software - Boston) ; www-ws-desc@w3.org
Sent: Tuesday, July 19, 2005 9:32 PM
Subject: Re: Whoops - Example is invalid upate attached



James,

Ignore, my comments below. After looking closer, I now see you wanted me
to look at SchemaA.xsd, not the instance document.  It says:

       <!--  Note that the import below ONLY imports schema "B".
Schema"C" is imported by declaration from wityhin schema "B", so you
will notsee it here  -->

The following reference is invalid:

                               <xs:element ref="C:ElementFromC"
minOccurs="1"/>

You claimed it was valid, but I validated it myself and got the
following error message:

Severity        Description        Resource        In Folder
Location        Creation Time
2        src-resolve.4.2: Error resolving component 'C:ElementFromC'. It
was detected that 'C:ElementFromC' is in namespace
'http://www.testC.com', but components from this namespace are not
referenceable from schema document
'file:///D:/workspaces/James/Example/data/RLG/MISC/WSDL%202.0%20Problem%
20Examples/SchemaA.xsd'. If this is the incorrect namespace, perhaps the
prefix of 'C:ElementFromC' needs to be changed. If this is the correct
namespace, then an appropriate 'import' tag should be added to
'file:///D:/workspaces/James/Example/data/RLG/MISC/WSDL%202.0%20Problem%
20Examples/SchemaA.xsd'.        SchemaA.xsd
Example/data/RLG/MISC/WSDL 2.0 Problem Examples        line 18
July 20, 2005 12:23:32 AM

The error message says you need to import namespace C.

I am using the Xerces parser for validation (actually integrated in the
Eclipse Web Tools Platform which you can download from [1]. How are you
validating your schema?

[1] http://eclipse.org/webtools


Arthur Ryman,
Rational Desktop Tools Development

phone: +1-905-413-3077, TL 969-3077
assistant: +1-905-413-2411, TL 969-2411
fax: +1-905-413-4920, TL 969-4920
mobile: +1-416-939-5063, text: 4169395063@fido.ca
intranet: http://labweb.torolab.ibm.com/DRY6/


Arthur Ryman/Toronto/IBM
07/20/2005 12:00 AM To"RDBMS" <RDBMS@aol.com>, WSD WG
cc"Booth, David \(HP Software - Boston\)" <dbooth@hp.com>
SubjectRe: Whoops - Example is invalid  upate attachedLink






James,

I now undertand the confusion. In your example, you give an XML instance
document, ExampleSchemaHierarchy.xml, that contains elements declared in
the other schemas. In that case there is no need for an xs:import.

That is not what we are talking about in the WSDL 2.0 spec. There we are
taking about refering to element declarations via QNames.

When a WSDL document refers to an element declaration by QName, for
example to declare the messages in an operation, then it must have an
xs:import for the namespace of the element it is refering to. This is
just like in XSD when you build up a new element declaration from other
element declarations.

Arthur Ryman,
Rational Desktop Tools Development

phone: +1-905-413-3077, TL 969-3077
assistant: +1-905-413-2411, TL 969-2411
fax: +1-905-413-4920, TL 969-4920
mobile: +1-416-939-5063, text: 4169395063@fido.ca
intranet: http://labweb.torolab.ibm.com/DRY6/


"RDBMS" <RDBMS@aol.com>
07/19/2005 03:57 PM Please respond to
"RDBMS"

ToArthur Ryman/Toronto/IBM@IBMCA, "Booth, David \(HP Software -
Boston\)" <dbooth@hp.com>
cc
SubjectWhoops - Example is invalid  upate attached







Hi David, Arthur,

In my haste, I found that I had incorporated and invalid type
declaration.

In the attached, I've corrected it.

Thanks !
J. Bean
P.O. Box 30171
Phoenix, AZ  85046-0171

RDBMS@aol.com
XML-Guy@hotmail.com
Received on Thursday, 21 July 2005 17:06:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:58:36 GMT