473,216 Members | 1,308 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,216 software developers and data experts.

Determine schemas used by document

Hi,

Using .Net 2.0 what is the best way to determine the list of schemas used by
a XmlDocument.

Thanks

Donal
May 17 '06 #1
5 2132


Donal McWeeney wrote:
Using .Net 2.0 what is the best way to determine the list of schemas used by
a XmlDocument.


Each XmlDocument instance has a property named Schemas
<http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.schemas(VS.80).aspx>
Is that what you are looking for? Note sure what kind of "use" you have
in mind.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 17 '06 #2
Schemas is empty and only used (I think) for the purposes of validation.

I want to do two things:

- dynamically determine what schemas are referenced in a document so I can
build a XmlSchemaSet with the correct file paths to the actual schema files
for validating the document.

- check if a document uses a specific schema and if it does change that
schema name to a different schema...

Thanks

Donal

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ug**************@TK2MSFTNGP05.phx.gbl...


Donal McWeeney wrote:
Using .Net 2.0 what is the best way to determine the list of schemas used
by a XmlDocument.


Each XmlDocument instance has a property named Schemas
<http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.schemas(VS.80).aspx>
Is that what you are looking for? Note sure what kind of "use" you have in
mind.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

May 18 '06 #3


Donal McWeeney wrote:
Schemas is empty and only used (I think) for the purposes of validation.

I want to do two things:

- dynamically determine what schemas are referenced in a document so I can
build a XmlSchemaSet with the correct file paths to the actual schema files
for validating the document.

So currently you simply load an XML document into an XmlDocument object
but you want to validate while loading using the xsi:schemaLocation (or
xsi:noNamespaceSchemaLocaton) hints in the document?
Then you need to use an XmlReader with the proper settings e.g.

XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.ValidationFlags |=
XmlSchemaValidationFlags.ProcessSchemaLocation;
readerSettings.ValidationEventHandler += new
ValidationEventHandler(ValidationHandler);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(XmlReader.Create(@"file.xml", readerSettings));
// now Schemas is a filled XmlSchemaSet
Console.WriteLine(xmlDocument.Schemas.Count);

I don't think there is any need to look for the schemas yourself, the
framework does that automatically if you use the proper settings as
shown above.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 18 '06 #4


Donal McWeeney wrote:
- check if a document uses a specific schema and if it does change that
schema name to a different schema...


Does that mean you want to read out the xsi:schemaLocation attribute and
then change its value?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 18 '06 #5
Hi Martin,

thanks for the info...
- check if a document uses a specific schema and if it does change that
schema name to a different schema...


Does that mean you want to read out the xsi:schemaLocation attribute and
then change its value?


In this case changing the namespace name.

I dont think xsi:schemaLocation will work for me... thats why I have to do a
manual mapping.
May 18 '06 #6

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

Similar topics

0
by: Tony Prichard | last post by:
Hi I would like to specify an XML schema that would allow an XML document to be included within another XML document. The following example schema gives an idea of what we're trying to achieve ...
0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
0
by: Steve Jorgensen | last post by:
I recently produced an XML Schema to support several kinds of transactions within a particular business domain. In the process, I learned pretty much all of how W3C XML Schema works, learned some...
4
by: anonymous | last post by:
When I use the schema collection to apply many schemas to one XML instance document, I get an error if I do not qualify every element with the appropriate namespace. Both the W3C site and this...
3
by: Modica82 | last post by:
Hi All, I am in the process of designing a web service for my company. It is my first commercial web service, so i think my "Hello World" coding model wont quite cut it here :). Anyway, i am...
6
by: petermichaux | last post by:
Hi, Is there a way to determine the name of a JavaScript file from inside the very same file? Thanks, Peter
3
by: M Borkan | last post by:
Can anyone tell me how to access the encodingStyle in a client from a SoapExtension? In particular, I'd like to know the style in SoapClientMessage in the SoapMessageStage.BeforeSerialize. I'm...
5
by: Robert Dufour | last post by:
With system.web.mail in VS2003, doing some tests, using localhost from IIS as server, I noticed that my code queues the messages OK, but when changing sender addresses I see that the mail message...
3
by: Water Cooler v2 | last post by:
Sorry for asking this beginner question. I've written DTDs so far and read about XML Schemas. I understand that they are a replacement of the DTD fundamentally, and therefore allow for the...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.