469,613 Members | 1,195 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

Namespace prefix in XSD


Hello!

I have an existing SOAP message which looks like:

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<xsi:MaintainCTOBomResponse
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:string">...

and I need to define an XSD for it.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsi:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsd:element name="Envelope">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Body" form="qualified">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MaintainCTOBomResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return">
<xsd:complexType>
<xsd:sequence>
...
<xsd:attribute name="type"/>

When I validate the XML with XML Spy it says: "Mandatory element
'MaintainCTOBomResponse' expected in place of 'xsi:MaintainCTOBomResponse'".

I cannot change the XML, how can I add the namespace prefix in the XSD
so that the xsi:MaintainCTOBomResponse element and the return xsi:type
attribute can successfully be validated? Thanks for your help.
Regards, Tanja
Nov 17 '06 #1
1 5669
Hi,

It is not possible to define more than one namespace within a single xml
schema. However, it is possible to reuse an xml schema with a different
namespace by importing it:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:prefix="---namespace-of-MaintainCTOBomResponse---">
<xsd:import namespace="---namespace-of-MaintainCTOBomResponse---"
schemaLocation="---schema-with-MaintainCTOBomResponse---.xsd"/>
<xsd:element name="Envelope">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Body" form="qualified">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="prefix:MaintainCTOBomResponse"/>

Gerben Abbink
www.xmlblueprint.com
"Tanja Schaettler" <sc*****@gmx.dewrote in message
news:ej**********@online.de...
>
Hello!

I have an existing SOAP message which looks like:

<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<xsi:MaintainCTOBomResponse
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:string">...

and I need to define an XSD for it.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsi:schema targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsd:element name="Envelope">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Body" form="qualified">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MaintainCTOBomResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return">
<xsd:complexType>
<xsd:sequence>
...
<xsd:attribute name="type"/>

When I validate the XML with XML Spy it says: "Mandatory element
'MaintainCTOBomResponse' expected in place of
'xsi:MaintainCTOBomResponse'".

I cannot change the XML, how can I add the namespace prefix in the XSD so
that the xsi:MaintainCTOBomResponse element and the return xsi:type
attribute can successfully be validated? Thanks for your help.
Regards, Tanja

Nov 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John L. Clark | last post: by
25 posts views Thread by kj | last post: by
3 posts views Thread by Mike Dickens | last post: by
4 posts views Thread by Krishna Tulasi via .NET 247 | last post: by
5 posts views Thread by pneumoconi | last post: by
5 posts views Thread by David Thielen | last post: by
13 posts views Thread by Axel Dahmen | last post: by
2 posts views Thread by scottpet | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.