Re xsd:string not validly derived

Hi Jenni,

I had the namespace already I pasted wrong one sorry for it..
Well I was writing a schema for the state to either integer or string...But
as a matter of fact I came down to check how to make it work with string
itself and move on to add the different cases..Infact my orginal schema was
like

<xsd:simpleType>
  <xsd:restriction>
   <xsd:simpleType>
     <xsd:union memberTypes='xsd:integer xsd:string'/>
   </xsd:simpleType>
   <xsd:pattern value='1'/>
   <xsd:pattern value='2'/>
   <xsd:pattern value='(A|ZK)'/>
  </xsd:restriction>
 </xsd:simpleType>

But then I had to add the soap encoding attribute too and that is when I
couldn't figurre  out a way to do it...

Could you help me out..
Thanks,
JK


-----Original Message-----
From: xmlschema-dev-request@w3.org
[mailto:xmlschema-dev-request@w3.org]On Behalf Of Jeni Tennison
Sent: 12 July 2002 14:43
To: xmlschema-dev@w3.org; Jaikrishnan Pillai
Subject: Re: xsd:string not validly derived



Hi JK,

> I am validating the schema using xerces.The xml I have is
>
> <?xml version='1.0' encoding='UTF-8'?>
> <ns1:getCities
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ns1="http://tempuri.org/forecast.WeatherForecast"
> SOAP-ENV:encodingStyle="http://xml.apache.org/xml-soap/literalxml">
> <state xsi:type="xsd:string"
>
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">hh</state
>
> </ns1:getCities>

First, you might have problems with this because the namespace
associated with the prefix 'xsd' isn't declared anywhere. You should
have a namespace declaration for the XMLSchema namespace:

<?xml version='1.0' encoding='UTF-8'?>
<ns1:getCities
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ns1="http://tempuri.org/forecast.WeatherForecast"
  SOAP-ENV:encodingStyle="http://xml.apache.org/xml-soap/literalxml">
<state xsi:type="xsd:string"

SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">hh</state
>
</ns1:getCities>

Second, you can't say that the element state has the type xsd:string
because it doesn't -- xsd:string is a simple type, and elements can
only have a simple type if they have simple content (contain only
text) and don't have any attributes. Your state element has got an
attribute, so it can't have a simple type.

Third, you can only use xsi:type to explicitly declare the type of an
element if the type that you name in xsi:type is derived from the type
that you use to declare the element. To use the xsi:type attribute on
the state element to say that it has the type of xsd:string, the state
element would have to be declared as either xsd:anySimpleType or
xsd:anyType. In your schema, it's declared as being of a complex type
extended from xsd:string.

I'm not sure why you're using xsi:type at all here, since you've
declared that the state's content is a string in the schema, you don't
need to say it again in the instance. Let us know why you want to use
xsi:type here and we'll see if there's another solution that can help.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 12 July 2002 12:30:23 UTC