Groups | Blog | Home
all groups > dotnet xml > january 2006 >

dotnet xml : XML with no schemaLocation


CB
1/27/2006 5:35:18 AM
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
Martin Honnen
1/27/2006 2:47:24 PM


[quoted text, click to view]

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/>


[quoted text, click to view]

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
AddThis Social Bookmark Button