Altova Mailing List Archives


Re: MSXML 4 Not seeing missing elements when validating....

From: "Joe Fawcett" <joefawcett@----------.------>
To: NULL
Date: 9/28/2005 9:58:00 AM
"WHoit" <WHoit@d...> wrote in message 
news:56206678-E851-4EA1-AC37-DD6831F7CA50@m......
>I don't think I follow you - MY XML files have this beginning:
> <?xml version="1.0" encoding="UTF-8"?>
> <myParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="Schemas/myParametersSchema.xsd">
>
> My VB Code accesses XML file this way:
> Dim xmlparams As New DOMDocument40
> xmlparams.async = False
> xmlparams.validateOnParse = True
> xmlparams.resolveExternals = True
> xmlparams.Load currentparamsfile
> If xmlparams.parseError <> 0 Then
>    reason = xmlparams.parseError.reason & " at line " &
> xmlparams.parseError.Line & ", position " & xmlparams.parseError.linepos
>    msgbox "****ERROR - Parameters xml file is most likely malformed:" &
> vbCrLf & reason
> End If
>
> Now, if an element within my XML file is incorrect (as I mentioned in my
> original post), I get a parsing error.
>
> However, if an element is missing - no error. (This is the problem I need to
> solve)
>
> So why do you think it's not validating?
>
> "Joe Fawcett" wrote:
>
I don't in that case.
You originally said you were "using a namespace declaration which indicates the 
schema".
You are not, using a namespace declaration is totally separate from declaring a 
schema.
Usinga namespace is like:
<xsl:stylesheet xmlns:myNs=http://myDoamin.com/namespaces/namespace1 ....

or in your particular case

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


You are correctly declaring a schema using:

xsi:noNamespaceSchemaLocation="Schemas/myParametersSchema.xsd"

Although you need to have the first, which declares the namespace prefix mapping 
so that the xsi prefix is recognised in the second statement the two are 
separate things.

Have you tried validating using the SchemaCache instead of relying on the parser 
to find the file?


-- 

Joe (MVP - XML)

https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5 


Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.