473,626 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2153


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.xmld ocument.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*******@yaho o.de> wrote in message
news:ug******** ******@TK2MSFTN GP05.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.xmld ocument.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:schemaLocat ion (or
xsi:noNamespace SchemaLocaton) hints in the document?
Then you need to use an XmlReader with the proper settings e.g.

XmlReaderSettin gs readerSettings = new XmlReaderSettin gs();
readerSettings. ValidationType = ValidationType. Schema;
readerSettings. ValidationFlags |=
XmlSchemaValida tionFlags.Proce ssSchemaLocatio n;
readerSettings. ValidationEvent Handler += new
ValidationEvent Handler(Validat ionHandler);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Loa d(XmlReader.Cre ate(@"file.xml" , readerSettings) );
// now Schemas is a filled XmlSchemaSet
Console.WriteLi ne(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:schemaLocat ion 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:schemaLocat ion attribute and
then change its value?


In this case changing the namespace name.

I dont think xsi:schemaLocat ion 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
1346
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 ServiceResponse.xsd -------------------- <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
0
1414
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 the common type definitions from 1 or more of the component XML schemas rather than just explicitly adding the common definitions in every XML schema we create. This works great from a definition and validation point of view, but I
0
1257
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 Schematron, read up on XML design patterns and best practices, and thought I knew what I was doing. Since there was more overlap than not between the contents of the different transaction types, I designed a single schema with a single root, and...
4
1677
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 article (http://www.xfront.com/ZeroOneOrManyNamespaces.html) imply that I can submit an XML instance without having to qualify each element. How do I accomplish this while still using .Net & the
3
1292
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 writing a design document for it, and want to provide XSD Schema information for XML used. My question is, do i provide XSD schemas for the XML being passed into the system, and the XML returned, or do i just do it for the XML being passed in....
6
1614
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
1814
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 trying to determine if the message encodingStyle is document/literal or rpc/encoding (or document/encoding). From the SoapClientMessage I can see in the debugger that there is a value for message.protocol.EncodingNs and for...
5
1572
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 ends up in the Bad folder. I need to know when that happens since the e-mails are of critical importance. How can I detect in my code, if an e-mail got queued but the actual transmission from the server was unsuccessfull and how can I find what the...
3
3657
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 validation of an XML document. My question really is: Why do we need XML Schemas other than for validation of an XML document? I am more interested in knowing if already available
0
8272
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
8205
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
8713
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8370
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,...
1
6126
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.