You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Daniel Jackson <af...@gmail.com> on 2008/04/18 09:09:27 UTC

Understanding how to properly validate xmls with xsds

Hi,

I'm trying to write an application that validates XMLs with XSD Schemas.
However I ran into some issues that I don't understand how I should handle
them.

1. Suppose I have this XML file:
<root xmlns="http://foo">
<child />
</root>

What is the right way to handle this? I saw that when using XML Spy schema
validation mechanism the editor adds an attribute to <root> called
'externalSchemaLocation' which contains a pair of "namespace path".
When that attribute appears in the XML, Xerces automatically calls
resolveEntity therefore properly validates the XML. But if the XML is as it
appears above, Xerces will parse the XML without errors even though I didn't
supply it with a matching schema.
My solution to this as of right now is to go over the XML and search
"xmlns", then I collect all the namespaces I find and call loadGrammar. But
I'm not sure that this is the right way to do this.

2. The XML looks the same however I have 2 schemas with namespace
'http://foo'. How will I know which one to return in resolveEntity? At the
moment what I do is create a new schema with the same namespace and include
the other 2. Is this how you're suppose to deal with this situation?

Thanks in advance.
-- 
View this message in context: http://www.nabble.com/Understanding-how-to-properly-validate-xmls-with-xsds-tp16760961p16760961.html
Sent from the Xerces - C - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org