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

Home Posts Topics Members FAQ

second namespace in same schema

Hi all,
I wish to create a namespace other than the default one.
Let's say, the Schema looks like:

-----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:d="http://www.geodesy.org/dam"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
<xs:element name="River">
<xs:complexType >
<xs:sequence>
<xs:element name="Length" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----------------------------------------------------------------------

Now, I wish that a new element is added to this schema which belongs
to another namespace (and not the default one). Is this possible?

Thanks.
Jul 20 '05 #1
2 1935


Zombie wrote:

I wish to create a namespace other than the default one.
Let's say, the Schema looks like:

-----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:d="http://www.geodesy.org/dam"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
I guess you want
targetNamespace ="http://www.geodesy.org/dam"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
<xs:element name="River">
<xs:complexType >
<xs:sequence>
<xs:element name="Length" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----------------------------------------------------------------------

Now, I wish that a new element is added to this schema which belongs
to another namespace (and not the default one). Is this possible?


You need a second schema for the second namespace (make sure you set the
targetNamespace there), then you can use <xs:import> to import that
schema into the first schema.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen <ma*******@yaho o.de> wrote in message news:<41******* *@olaf.komtel.n et>...
Zombie wrote:

I wish to create a namespace other than the default one.
Let's say, the Schema looks like:

-----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:d="http://www.geodesy.org/dam"
xmlns:xs="http://www.w3.org/2001/XMLSchema"


I guess you want
targetNamespace ="http://www.geodesy.org/dam"

[snip] [snip] [snip]
-----------------------------------------------------------------------

Now, I wish that a new element is added to this schema which belongs
to another namespace (and not the default one). Is this possible?


You need a second schema for the second namespace (make sure you set the
targetNamespace there), then you can use <xs:import> to import that
schema into the first schema.

I will rephrase my query and put it in the proper context: I wish to
create an XML schema that successfully validates an XML file
containing any new unknown elements. Assume that the schema has only
"Name" and "Address" elements declared. If the XML contains the
elements "Name", "Address" _and_ "Age", then only "Name" and "Address"
should get validated and "Age" should be ignored.

I have found a way to do this by using <xs:any namespace="##ot her">.
However, I am facing some problems with it. Here is the detailed
decription:

I have a schema (schema0)to which new elements get added over time (no
elements are ever removed). These different schemas are called
schema0, schema1 etc. Corresponding to each of these, I will have XML
files xml0, xml1 etc. I want xml1 to get successfuly validated against
schema1 as well as schem0. Similarly, xml2 should get validated
against schema2, schema1 and schema0...and so on.
To achieve this, I use <xs:any namespace="##ot her"> in schema0.
<<schema0 and xml1 are given at the end>>

The trick is to use a namespace (xmlns:d) for the new element
"<d:Age>" in xml1. Due to <xs:any namespace="##ot her">,schema0 allows
this unknown element.
Now, the problem is that I have to validate xml1 against schema1 too.
Schema1 is extended from schema0 by defining another element "Age" in
namespace "d".
The constraint here is that the whole of the schema1 should be
contained in a single file. How do I declare this new element and
namespace along with schema0?
Clear as mud? :D

Thanks for your time!

schema0:
----------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" attributeFormDe fault="unqualif ied">
<xs:element name="River">
<xs:complexType >
<xs:sequence>
<xs:element name="Name" type="xs:string "/>
<xs:any namespace="##ot her"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
---------------------------------------------------------------------
xml1:
---------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<River xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "D:\schema1.xsd "
xmlns:d="http://www.geodesy.org/dam" >
<Name>The Three Gorges Dam</Name>
<d:Age>12</d:Age>
</River>
---------------------------------------------------------------------
Jul 20 '05 #3

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"...
2
2012
by: Dale Anderson | last post by:
I have a schema that I'm trying to read. The schema has an element named 'GrantApplication' and one with a namespace prefix named 'SF424:GrantApplication'. When I try to read this schema in, I get an exception saying 'A datatable named 'GrantApplication' alread belongs to this dataset'. Why is dotnet not recognizing the namespace prefix and treating these like two separate elements? Thanks for your help.
2
2194
by: Che | last post by:
Greetings, I am writing an application that uses an extendible XML file. in order to validate that XML I use a main XSD and in additional - few more extensions XSD's that uses the types in the main XSD as base types. my clients can define their own XSD's extensions and use my generic application to process their XML's. The problem:
1
2314
by: Wallace | last post by:
Hi all, I have a problem on validating a xml fragment using a single namespace schema which spread across multiple schema files using include in the master schema file. No matter how I change the xml fragment (to include default namespace xmlns='urn:xxx:yy' and any other namespace it may have), I still get the same error. 'urn:xxx:yy:Header' element is not declared. An error occurred at , (1, 2).
12
8569
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
4
1703
by: R. Nachtsturm | last post by:
Hi, Question (in short): can i somehow use the namespace tag to define that a class in its own file is actually the subclass (namespace wise) of another class? Explanation: for example, if I have one class named "Schema", this class should have a public sub class named "Table", such as:
1
1888
by: ax | last post by:
Dear Experts, I really worry about the following problem.. There is one XML File on my PC located at C:\Test. Hence, there are 2 XSD files on the same path I make an absolut reference in the XML file to the 2 XSD files. xmlns:address="C:\Test\file_address.xsd"
3
4980
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml version="1.0" encoding="utf-8" ?> <thing xmlns="urn:thing-schema-v1"> <foo>foo thing</foo> <bar>bar thing</bar>
3
3498
by: Jon | last post by:
I have an xml document like so... <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:ng="http://newsgator.com/schema/extensions"> <channel> <title></title> <link></link> <description></description> ...
0
9684
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
9530
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
10236
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
10182
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
10017
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
9055
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
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.