Altova Mailing List Archives
>microsoft.public.xml Archive Home
>Thread Prev - Re: MSXML 4 Not seeing missing elements when validating....
Re: MSXML 4 Not seeing missing elements when validating....
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