XML validation with libxml2 and msxml
-
Hello, I need to validate an XML file using an XSD scheme imposed by a provider. For that I use the library libxml2 version 2.9.4 and msxml6 under Windows and I get different results. With libxml2 the XML file is not valid on Windows or Linux. With MSXML6 the XML file is considered valid. Below are some simplified examples. To easily validate the XML file with the XSD, I use Microsoft Visual Studio (msxml) and compare with Notepad ++ (XMLTools plugin that apparently uses libxml2). XML file :
XSD file :
By adding a "?" at the end of the control pattern, the validation is ok with libxml ** and ** msxml: \d\p{Lu}\p{Lu}\p{Lu}\d\d\d\p{Lu}\p{Lu}(\p{Lu}|\d|)?
Not at all comfortable with regular expressions and XSDs I need help on this topic.
Do you think that libxml is stricter than msxml? is the interpretation of the regular expression ambiguous?Thank you very much !
-
Hello, I need to validate an XML file using an XSD scheme imposed by a provider. For that I use the library libxml2 version 2.9.4 and msxml6 under Windows and I get different results. With libxml2 the XML file is not valid on Windows or Linux. With MSXML6 the XML file is considered valid. Below are some simplified examples. To easily validate the XML file with the XSD, I use Microsoft Visual Studio (msxml) and compare with Notepad ++ (XMLTools plugin that apparently uses libxml2). XML file :
XSD file :
By adding a "?" at the end of the control pattern, the validation is ok with libxml ** and ** msxml: \d\p{Lu}\p{Lu}\p{Lu}\d\d\d\p{Lu}\p{Lu}(\p{Lu}|\d|)?
Not at all comfortable with regular expressions and XSDs I need help on this topic.
Do you think that libxml is stricter than msxml? is the interpretation of the regular expression ambiguous?Thank you very much !
The question mark makes the preceeding portion optional. That is it might be absent or present one time but not multiple times. But you have an empty OR condition:
(\p{Lu}|\d|)
I would change it to
(\p{Lu}|\d)
I guess that the regex implementation used by libxml fails here while those of MSXML ignores it.