Issue 31808 — xmlToStruct fails when schemaLocation points to non-existing XML schema
Status: Planned for resolution in 10.4.01
Solution available in patch(es): 10.3.02.023 9.7.05.036
Description:
Summary: The xmlToStruct statement fails when the schemaLocation or noNamespaceSchemaLocation attribute of a XML document points to a non-existing XML schema location. Environment: +Uniface: * Version 9.5.01 (and higher) +Operating System: * OS independent +Database: * DBMS independent Symptoms: The schemaLocation attribute can be used to specify the location of a XML schema for a specific namespace. And the noNamespaceSchemaLocation attribute references an XML Schema document that does not have a target namespace. In case the specified XML schema (XSD file) is not valid then the xmlToStruct statement will fail with the error -1503 ("Fatal error encountered during schema scan"). This is not excepted, since the schema files should only be read when using structToXml/schema. Consider the following XML (mysample.xml): <?xml version="1.0"?> <root xmlns="https://www.uniface.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.uniface.com https://www.uniface.com/xsd/uniface.xsd"> <text>this is a text</text> </root> When executing the following statement then the error -1503 is returned: xmlToStruct vStruct, "mysample.xml" Expectation: xmlToStruct should ignore the schemaLocation attribute.
Workaround:
Remove the namespace attribute before using xmlToStruct. E.g. vFileName = "mysample.xml" fileload vFileName, vXml vXml = $replace(vXml, 1, 'xsi:schemaLocation="(*)"', "") vXml = $replace(vXml, 1, 'xsi:noNamespaceSchemaLocation ="(*)"', "") xmltostruct vStruct, vXml
Notes: