Hi Tom,
Try adding a noNamespaceSchemaLocation attribute in the root element of your
xml.
If you pass the xsd path in the DOM Parse XML source schema parameter, the
value for this attribute seems to be ignored (I think i.e. empirical).
So something like this :
<?xml version="1.0" encoding="UTF-8"?>
<registrations
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="data.xsd-OrWhatever">
<registration>
<sWebSource>WS_SQLReg_MO</sWebSource>
<sProduct>State</sProduct>
<sisEligCheckRequired>True</sisEligCheckRequired>
</registration>
</registrations>
That should do the trick :-)
I don't know why this is the case (the document validates fine with other
tools, it is just empirical (a workaround).
Also, if your path of your document is a unc path "\\share\dir\schema/xsd", the
validation will fail.
The following xml should validate (and does validate with xmllint, oxygen,
etc…) :
<?xml version="1.0" encoding="UTF-8"?>
<registrations>
<registration>
<sWebSource>WS_SQLReg_MO</sWebSource>
<sProduct>State</sProduct>
<sisEligCheckRequired>True</sisEligCheckRequired>
</registration>
</registrations>
$ xmllint --noout --schema data.xsd data.xml
data.xml validates
Maybe it is a bug. I never bothered to report it.
XSD is such a great underestimated technology IMOHO. I allows you, when you
think about it, to write much simpler since you don't have to handle errors
because of unexpected format.
Once your document is validated, you know what to expect in the document.
The same way you use xsd before parsing a document, you should use xsd before
sending a document.
C_TEXT($vt_xmlPath;$vt_xsdPath)
$vt_xmlPath:="data.xml"
$vt_xsdPath:="data.xsd"
C_BOOLEAN($vb_valid)
C_ALPHA(32;$va_domRootRef)
$va_domRootRef:=DOM Parse XML source($vt_xmlPath;True;$vt_xsdPath)
$vb_valid:=(ok=1)
ASSERT($vb_valid;"file \""+$vt_xmlPath+"\" is not validated by schema
\""+$vt_xsdPath+"\"")
If ($vb_valid)
DOM FERMER XML($va_domRootRef)
Else// handle invalid xml here
End if
HTH
Bruno
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************