How do I read in an XSD file that includes and imports lots of other XSD
files, so that I can enumerate all the elements/attributes defined by the XSD. 5 9164
tony lock wrote:
How do I read in an XSD file that includes and imports lots of other XSD
files, so that I can enumerate all the elements/attributes defined by the XSD.
Load the schema into an XmlSchemaSet: http://msdn.microsoft.com/en-us/libr...maset.add.aspx
then use the properties/methods of the XmlSchemaSet to access the
elements/attributes/types defined.
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
XmlSchemaSet can do this (see below); note that the set.XmlResolver needs to
be able to locate the related schemas, which is easiest if you start with
something like an XmlReader that knows where the file came from [in
contrast, say, to a MemoryStream] - but if you need to you can write your
own XmlResolver (I've written resolvers from resource files, databases,
etc).
XmlSchemaSet set = new XmlSchemaSet();
set.Add(XmlSchema.Read(XmlReader.Create("XMLSchema 1.xsd"), null));
set.Compile();
foreach (XmlSchemaType obj in set.GlobalTypes.Values)
{
Console.WriteLine("{0}: {1}", obj.Name, obj.SourceUri);
}
Marc
Thanks for that unfortunately when I do the compile I get an exception
The global attribute 'http://www.w3.org/XML/1998/namespace:lang' has already
been declared.
It appears all the xsd's which are being imported include imports of the
basic declarations. Is there any way to tell the XmlSchemaSet to ignore all
but the first definition of any element/attribute
"Marc Gravell" wrote:
XmlSchemaSet can do this (see below); note that the set.XmlResolver needs to
be able to locate the related schemas, which is easiest if you start with
something like an XmlReader that knows where the file came from [in
contrast, say, to a MemoryStream] - but if you need to you can write your
own XmlResolver (I've written resolvers from resource files, databases,
etc).
XmlSchemaSet set = new XmlSchemaSet();
set.Add(XmlSchema.Read(XmlReader.Create("XMLSchema 1.xsd"), null));
set.Compile();
foreach (XmlSchemaType obj in set.GlobalTypes.Values)
{
Console.WriteLine("{0}: {1}", obj.Name, obj.SourceUri);
}
Marc
On Aug 19, 6:57*pm, tony lock <tonyl...@discussions.microsoft.com>
wrote:
Thanks for that unfortunately when I do the compile I get an exception
The global attribute 'http://www.w3.org/XML/1998/namespace:lang'has already
been declared.
It appears all the xsd's which are being imported include imports of the
basic declarations. Is there any way to tell the XmlSchemaSet to ignore all
but the first definition of any element/attribute
No. XmlSchemaSet only reads well-formed and valid XML Schema
declarations. If an .xsd file, after include expansion, ends up
defining several things twice, it's just not valid. If the schemas are
your own, you should consider fixing them.
Unfortunately they are not.
"Pavel Minaev" wrote:
On Aug 19, 6:57 pm, tony lock <tonyl...@discussions.microsoft.com>
wrote:
Thanks for that unfortunately when I do the compile I get an exception
The global attribute 'http://www.w3.org/XML/1998/namespace:lang'has already
been declared.
It appears all the xsd's which are being imported include imports of the
basic declarations. Is there any way to tell the XmlSchemaSet to ignore all
but the first definition of any element/attribute
No. XmlSchemaSet only reads well-formed and valid XML Schema
declarations. If an .xsd file, after include expansion, ends up
defining several things twice, it's just not valid. If the schemas are
your own, you should consider fixing them. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Weston C |
last post by:
I know of course that you can use <script src=""></script> in an HTML
document to include javascript code you don't want to spill all over the
page.
I'm wondering if there's a way to include...
|
by: peter |
last post by:
I use the click-to-expand menu at
http://javascript.internet.com/navigation/click-to-expand-menu.html
This works fine, but is there a way to expand or collapse all the
menus?
An example of how...
|
by: WStoreyII |
last post by:
what exactly is the difference between import and include?
For Example if i had a schema called common, that had some common elements
that i use such as address, phone ect. And then i created a...
|
by: James J. Besemer |
last post by:
I would like to champion a proposed enhancement to Python. I describe the
basic idea below, in order to gage community interest. Right now, it's only
an idea, and I'm sure there's room for...
|
by: Konstantin Andreev |
last post by:
Recently I became interested, - Are the data, bulk loaded in the table with
LOAD utility, consume the same disk space as loaded with IMPORT utility? The
answer turned out to be NOT !
Here is a...
|
by: jrs362 |
last post by:
One more problem...
I need to write a method(Which i'm calling "expand") that takes an int array as one of its parameters and returns a new int array that is 5 elements longer. The contents of the...
|
by: Nospam |
last post by:
I don't know what it is I am doing wrong, I am trying to get the menus to
either expand or contract based on their previous states, i.e if already
expanded if clicked again contract, and if...
|
by: hemantbasva |
last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
|
by: liz0001 |
last post by:
I have seen many examples on how to use the .load() function to load in static elements, but I am trying to load a dynamic element, specifically a scrollable.
I have gotten it to the point where:...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |