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

XML with no schemaLocation

CB
I have some XML instance documents that specify schemas via the xmlns
attribute.

I need to load these documents (with XmlDocument) and have them
verified against the XSD's that are mentioned.

However, the documents are intended to be shared between machines but
the location of where the XSD's are stored can vary from machine to
machine so I don't think it is possible for me to specify the
xsi:schemaLocation in the instance documents.

To load these documents and have them verified I can only think that I
should:

1. Load them once without validation
2. Parse the document and build a list of the namespaces they are
trying to use
3. Create an XmlSchemaSet and populate it with the known locations of
the schemas
4. Finally load them again with validation on using the schema set I
just built

Does this sound right?

thanks

Jan 27 '06 #1
1 2073


CB wrote:
I have some XML instance documents that specify schemas via the xmlns
attribute.
Sorry, but the xmlns attribute declares a namespace and does not specify
a schema.
XML namespaces specification is here:
<http://www.w3.org/TR/REC-xml-names/>

1. Load them once without validation
2. Parse the document and build a list of the namespaces they are
trying to use
3. Create an XmlSchemaSet and populate it with the known locations of
the schemas
4. Finally load them again with validation on using the schema set I
just built


Well XmlDocument is overhead if you just want to extract some
information so consider using XmlTextReader to extract the information
and only load with XmlDocument if you want to manipulate the document.

But consider changing the approach, there is one established way to give
a hint about schema locations within the document, if that is not
possible I would not try to hide that information elsewhere in the
document to have to go to such efforts, rather then make sure that
whoever sends you an XML document sends you the schema locations apart
from the document.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 27 '06 #2

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

Similar topics

1
by: Naresh Agarwal | last post by:
Hi I'm using SAX Parser of Xerces Java v2.4.0 for XML Parsing. I want to perform schema validations on the xml. The problem is that root element of XML document does not have...
1
by: John | last post by:
I have an input document that contains a large base64 encoded document. This document also declares a schema location in the root element. I want to write an XSL stylesheet that makes an exact...
0
by: Sarah Tegtmeier | last post by:
Hi I have a question about the correct use of the attribute xsi:schemaLocation. My programm has to process XML files where the value of this attribute causes some problems. The programm is...
0
by: Ron James | last post by:
I'm developing a GUI application in C#. I have a schema file (.XSD) and am able to serialize and deserialize the applications data using the schema file to an .XML file. (I'm using xsd.exe to...
0
by: davea | last post by:
I am trying to validate an XML instance document that contains elements from 2 different schema's. When I validate using .net I get the following error "Xml is invalid: The element...
2
by: kaush | last post by:
Hi all, I am trying to serialize a C# object into a XML document using "XmlSerializer" class. One of the elements of the XML document needs a "xsi:schemaLocation" attribute. I am not sure how to...
1
by: techie | last post by:
Hi, I am using an xml schema (Schema1.xsd) which refers to two other Schemas as follows. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:plcm-s="http://www.mycompany.com/plcm"...
2
by: grochmal | last post by:
I am trying to use XmlSerializer to serialize a class I have created specifically for generating an XML file. The problem is that the XML file must contain a xsi:schemaLocation attribute in my...
1
by: Marvin Massih | last post by:
I've searched the entire MSDN documentation and Google, but I just don't find a solution: I have an .xsd file from which I had xsd.exe create classes. How can I make the XmlSerializer write the...
0
by: =?Utf-8?B?Um9iaW5N?= | last post by:
Hi, I'm re-writing my WSDLs to remove the port number using a SoapExtensionReflector derived class. The ports are redirected at our firewall so they're not required in the WSDL. Here's my code:...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.