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

Multiple XSD Level for a single XML with multiple namespaces

Ok, I am not sure if it is possible. But what I'm trying to do is
validate an XML file with out having to add namespace in the xml.

What I mean is lets say I have 2 XSD
they have different namespaces and lvl2 is used in lvl using the
import feature

lvl1.xsd
-> lvl2.xsd

the xml I would like to validate would be as follow

<level1>
<level2>
<string>hello</string>
<Number>10</Number>
</level2>
<level1>
right now I have to define the namespace of a level to to use the
sublevel tag that way:
....
<l2:string>hello</l2:string>
<l2:Number>10</l2:Number>
....

my problem is I don't want the guy who write the xml to be aware of
the structure I use for the XSD. and I want the possibility of having
multiple tags with the same name having different signification based
on where they are placed in the schema.

what I though of is in someway, if he find a tag <level2> it
automaticaly switch the default namespace to the level2 and so on
until it reach </level2> where it would switch back to the level1
namespace.

I think what I want should be pretty easy to do but I just can't
manage make that work.

Thx in advance for your help
Nov 12 '05 #1
3 6270
There is no way of directly validating your instance based on multiple
prefix mappings for a namespace. It is possible, though, for you to play
with the namespaces (via the API) to create and maintain context to achieve
this. Are you using MSXML or System.XML?

If you want the user to not *know* about the namespace in yoru schemas then
why dont you put the schema content in one schema with no targetNamespace?
or even in one commo namespace?

Zafar
"John Smith" <me*********@hotmail.com> wrote in message
news:71**************************@posting.google.c om...
Ok, I am not sure if it is possible. But what I'm trying to do is
validate an XML file with out having to add namespace in the xml.

What I mean is lets say I have 2 XSD
they have different namespaces and lvl2 is used in lvl using the
import feature

lvl1.xsd
-> lvl2.xsd

the xml I would like to validate would be as follow

<level1>
<level2>
<string>hello</string>
<Number>10</Number>
</level2>
<level1>
right now I have to define the namespace of a level to to use the
sublevel tag that way:
...
<l2:string>hello</l2:string>
<l2:Number>10</l2:Number>
...

my problem is I don't want the guy who write the xml to be aware of
the structure I use for the XSD. and I want the possibility of having
multiple tags with the same name having different signification based
on where they are placed in the schema.

what I though of is in someway, if he find a tag <level2> it
automaticaly switch the default namespace to the level2 and so on
until it reach </level2> where it would switch back to the level1
namespace.

I think what I want should be pretty easy to do but I just can't
manage make that work.

Thx in advance for your help

Nov 12 '05 #2
well, my last message screwed when I tried to send it so I won't write
it again. But well thx for your input. I'll have to look how to do
that myself using System.XML.

Right now I'm only using the validator in Visual Studio .Net
(XML|Validate XML) but I get all kind of errors: the 'blablabla'
element is not defined but in XMLspy the schema is working perfectly.
They are not in the same project but they are part of the same
solution. So I'm kind of lost about what I'm doing wrong.

Anyway, thx for your help I'll look into that

"Zafar Abbas [MSFT]" <za****@microsoft.com> wrote in message news:<ua*************@TK2MSFTNGP12.phx.gbl>...
There is no way of directly validating your instance based on multiple
prefix mappings for a namespace. It is possible, though, for you to play
with the namespaces (via the API) to create and maintain context to achieve
this. Are you using MSXML or System.XML?

If you want the user to not *know* about the namespace in yoru schemas then
why dont you put the schema content in one schema with no targetNamespace?
or even in one commo namespace?

Zafar
"John Smith" <me*********@hotmail.com> wrote in message
news:71**************************@posting.google.c om...
Ok, I am not sure if it is possible. But what I'm trying to do is
validate an XML file with out having to add namespace in the xml.

What I mean is lets say I have 2 XSD
they have different namespaces and lvl2 is used in lvl using the
import feature

lvl1.xsd
-> lvl2.xsd

the xml I would like to validate would be as follow

<level1>
<level2>
<string>hello</string>
<Number>10</Number>
</level2>
<level1>
right now I have to define the namespace of a level to to use the
sublevel tag that way:
...
<l2:string>hello</l2:string>
<l2:Number>10</l2:Number>
...

my problem is I don't want the guy who write the xml to be aware of
the structure I use for the XSD. and I want the possibility of having
multiple tags with the same name having different signification based
on where they are placed in the schema.

what I though of is in someway, if he find a tag <level2> it
automaticaly switch the default namespace to the level2 and so on
until it reach </level2> where it would switch back to the level1
namespace.

I think what I want should be pretty easy to do but I just can't
manage make that work.

Thx in advance for your help

Nov 12 '05 #3
Internally, when validating a schema, .NET call a function
Schema.Compile. If the schema contains any include or import, those
url references needs to be resolved.
If you are currently using .NET framework 1.0, be advised that .NET
framework 1.0 does not implement/call a default XmlResolver.
It means that all schema containing include or import would fail, .NET
will not be able to validate the file against the schema.
Those schema will be valid in XMLSpy. XMLSpy will also be able to
validate the file against the schemas.
If you are using .NET framework 1.0, even
implementing a custom XmlResolver will not work, because it will not
be called, the overloaded version of function XmlSchema.Compile with
the Xml Resolver, XmlSchema.Compile( ValidationEventHandler,
XmlResolver) did not exist in framework 1.0. In framework 1.0, one
trick to bypass the problem is to merge both file. You can do that
manually, but you can also do that programatically: load both files,
take the types (complex and simple types) definition from the second
schema. Add every type definition to the first file (Don't forget to
add the namespace definitions). Validate the file against that new
schema.[list:a3563162a1]In .NET framework 1.1, you can also implement your
own XmlResolver derived class.[/list:u:a3563162a1]

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
47
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
6
by: Orgun | last post by:
Hi, I sent this message to the moderated c++ group too but it is waiting for moderator approval and I wanted to send here too. I am new to Design Patterns. I want to write a simple...
10
by: Aaron Gray | last post by:
AFAICT FireFox SVG does not work with DOM Level 1 constructs, it needs Namespaces. Is this correct ? Aaron
1
by: icfai | last post by:
hi friends.... I have got a problem regarding loading of multiple assemblies, actually its required for an editor which implements the intellisenseas in vb or dotnet. for that it is required to...
11
by: John | last post by:
Hi All, Although C# has Generics, it still does not support the generic programming paradigm. Multiple inheritance is required to support real generic programming. Here is a simple design pattern...
0
by: =?Utf-8?B?Q2FtZWw=?= | last post by:
For anyone who has utilised classes under XSD.exe and CodeDOM (please redirect me to another group perhaps if not here) please any ideas on how to translate the multiple namespaces present within...
1
camel
by: camel | last post by:
For anyone who has utilised classes under XSD.exe and CodeDOM, please any ideas on how to translate the multiple namespaces present within multiple XmlSchema , i.e., via xs:import, to multiple output...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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
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...
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,...

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.