Schema building help

J

johnsocs

All -

I am very stuck on building a schema for the following xml message. I
feel I'm very close as the message validates if I remove the
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
attribute from the doSpellingSuggestion element. Any help/pointers for
describing the encodingStyle attribute in my schema would be great.

Any help on this would be great.

Thanks.

-------------- Message -------------------

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>

<ns1:doSpellingSuggestion
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="urn:GoogleSearch">
<key xsi:type="xsd:string">QLgFC0VQFHJNq8RfD6sDbGCQD6710PlS</key>
<phrase xsi:type="xsd:string">rabbbit</phrase>
</ns1:doSpellingSuggestion>

</soapenv:Body>
</soapenv:Envelope>

------------ Schema ---------------

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:GoogleSearch"
version="1.0">

<xs:import namespace="urn:GoogleSearch"
schemaLocation="GoogledoSpellingSuggestion.xsd" />

<xs:element name="Envelope">
<xs:complexType>
<xs:sequence>
<xs:element name="Body">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns1:doSpellingSuggestion"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

---------------

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/encoding/"
targetNamespace="urn:GoogleSearch"
xmlns:ns1="urn:GoogleSearch"
version="1.0">

<xsd:element name="doSpellingSuggestion"
type="ns1:doSpellingSuggestion"/>

<xsd:complexType name="doSpellingSuggestion">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
<xsd:element name="phrase" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>
 
M

Martin Honnen

I am very stuck on building a schema for the following xml message. I
feel I'm very close as the message validates if I remove the
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
attribute from the doSpellingSuggestion element. Any help/pointers for
describing the encodingStyle attribute in my schema would be great.

Why do you need to write your own schema for that, a schema already
exists, you could just import it e.g.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
targetNamespace="urn:GoogleSearch"
xmlns:ns1="urn:GoogleSearch"
version="1.0">

<xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/"
schemaLocation="http://schemas.xmlsoap.org/soap/envelope/" />

<xsd:element name="doSpellingSuggestion"
type="ns1:doSpellingSuggestion"/>

<xsd:complexType name="doSpellingSuggestion">
<xsd:sequence>
<xsd:element name="key" type="xsd:string"/>
<xsd:element name="phrase" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute ref="soapenv:encodingStyle" />
</xsd:complexType>

</xsd:schema>


If you really think you need to implement it yourself then look at the
schema at
<http://schemas.xmlsoap.org/soap/envelope/>
how that works. It has a global declaration for the attribute and its type.
 
J

johnsocs

Thanks for the reply

The message fails to to compile with using xmllint using the above
schema

]# xmllint --schema GoogleSoapEnvelope.xsd GoogleMessage.xml
GoogledoSpellingSuggestion.xsd:18: element attribute: Schemas parser
error : Attribute ref. 'soapenv:encodingStyle', attribute 'ref': The
QName value {'http://schemas.xmlsoap.org/soap/envelope/',
'encodingStyle'} does not resolve to a(n) attribute declaration.
WXS schema GoogleSoapEnvelope.xsd failed to compile
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>

<ns1:doSpellingSuggestion xmlns:ns1="urn:GoogleSearch"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<key xsi:type="xsd:string">QLgFC0VQFHJNq8RfD6sDbGCQD6710PlS</key>
<phrase xsi:type="xsd:string">rabbbit</phrase>

</ns1:doSpellingSuggestion>

</soapenv:Body>
</soapenv:Envelope>
]#
 
M

Martin Honnen

The message fails to to compile with using xmllint using the above
schema

]# xmllint --schema GoogleSoapEnvelope.xsd GoogleMessage.xml
GoogledoSpellingSuggestion.xsd:18: element attribute: Schemas parser
error : Attribute ref. 'soapenv:encodingStyle', attribute 'ref': The
QName value {'http://schemas.xmlsoap.org/soap/envelope/',
'encodingStyle'} does not resolve to a(n) attribute declaration.

I do not use xmllint and I am not familiar with its schema processor.
The message suggests that it does not find the referenced attribute
declaration so either an import is missing or you need to provide the
imported schemas on the command line too to have the processor find it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top