473,796 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:MaintainCT OBomResponse
SOAP-ENV:encodingSty le="http://schemas.xmlsoap .org/soap/encoding/">
<return xsi:type="xsd:s tring">...

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:complexTyp e>
<xsd:sequence >
<xsd:element name="Body" form="qualified ">
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="MaintainC TOBomResponse">
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="return">
<xsd:complexTyp e>
<xsd:sequence >
...
<xsd:attribut e name="type"/>

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

I cannot change the XML, how can I add the namespace prefix in the XSD
so that the xsi:MaintainCTO BomResponse element and the return xsi:type
attribute can successfully be validated? Thanks for your help.
Regards, Tanja
Nov 17 '06 #1
1 5903
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-MaintainCTOBomR esponse---">
<xsd:import namespace="---namespace-of-MaintainCTOBomR esponse---"
schemaLocation= "---schema-with-MaintainCTOBomR esponse---.xsd"/>
<xsd:element name="Envelope" >
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="Body" form="qualified ">
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element ref="prefix:Mai ntainCTOBomResp onse"/>

Gerben Abbink
www.xmlblueprint.com
"Tanja Schaettler" <sc*****@gmx.de wrote 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:MaintainCT OBomResponse
SOAP-ENV:encodingSty le="http://schemas.xmlsoap .org/soap/encoding/">
<return xsi:type="xsd:s tring">...

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:complexTyp e>
<xsd:sequence >
<xsd:element name="Body" form="qualified ">
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="MaintainC TOBomResponse">
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="return">
<xsd:complexTyp e>
<xsd:sequence >
...
<xsd:attribut e name="type"/>

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

I cannot change the XML, how can I add the namespace prefix in the XSD so
that the xsi:MaintainCTO BomResponse 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
2725
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 namespace prefix, what is its namespace, if default namespaces do not apply? Are (either of) prefixed or non-prefixed attributes correct? For example, are the following equivalent: <html:br class="foo"...
25
3097
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 to/associated with? My understanding was that baz above belongs to some "default default namespace", but I have not been able to
3
10043
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" xmlns:ns1="abc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" media-type="text/xml" standalone="yes" version="1.0"/> <xsl:template match="/">
4
12169
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 = http://www.pdr.com\nhttps://extw3c.pdr.com/prism/b2b/schemas/TitleNotification.xsd;
4
20505
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 ss:Name="TKCSheet1"> </Worksheet> The existing xml doc is: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?>
5
5738
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 which looks something like this: <?xml version="1.0" encoding="utf-8"?> <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">...
5
2408
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 XmlNamespaceManager(xml.NameTable); context.AddNamespace("", "http://www.test.org"); context.AddNamespace("sns", "http://www.test.org/sub"); XmlNode node = xml.SelectSingleNode("/root", context);
18
7739
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); System.out.println(xp.evaluate(new InputSource(new FileInputStream("a.xml"))));
13
2529
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 applications are supposed to determine the proper validation DTD. In the following XML: ------------- <?xml version="1.0" ?>
2
21646
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: http://msdn2.microsoft.com/en-gb/library/system.xml.serialization.xmlnamespacedeclarationsattribute.aspx I get namespace prefixes in the document, but not on the root node. Specifically, the serializer does not work as described in the last
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9525
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10221
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10169
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.