473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 5881
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
25
by: kj | last post by:
Consider the following XML document: <?xml version='1.0' encoding='UTF-8'?> <bar:foo xmlns:bar='someuri'> <baz/> </bar:foo> What namespace does baz belong to? What is this namespace bound...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
4
by: AP | last post by:
Hi, I have a class that I wish to serialize to XML, part of which looks like this: public class TitleNotification { public string NoNameSpaceSchemaLocation =...
4
by: Krishna Tulasi via .NET 247 | last post by:
Hi, I am having trouble with creation of XML programmatically using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc: <Worksheet...
5
by: pneumoconi | last post by:
I've read a lot of posts on this subject each with a slightly different issue and from what I gather my code is fine. But its not. I'm trying to pull out the SQL query from a SQL report document...
5
by: David Thielen | last post by:
Hi; I set up my xml as follows: XmlDocument xml = new XmlDocument(); xml.Load(File.Open("data.xml", FileMode.Open, FileAccess.Read)); XmlNamespaceManager context = new...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
13
by: Axel Dahmen | last post by:
Hi, I've got a question on namespaces. After reading http://www.w3.org/TR/xml-names11 I still don't understand how namespaces are applied to attributes - particularly in regard to how processing...
2
by: scottpet | last post by:
Hi, I want to add a namespace prefix to the root node of an object I am serializing to XML. I have been reading though this article:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.