473,405 Members | 2,210 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,405 software developers and data experts.

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"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<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 1905


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"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<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*******@yahoo.de> wrote in message news:<41********@olaf.komtel.net>...
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="##other">.
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="##other"> 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="##other">,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"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="River">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:any namespace="##other"/>
</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:noNamespaceSchemaLocation="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
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...
2
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...
2
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...
1
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...
12
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
4
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...
1
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...
3
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...
3
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>...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.