[xsd-users] setValidationScheme

Zhang, Yan Yan.Zhang at navcanada.ca
Thu Dec 9 14:20:20 EST 2021


Hello there,
I got this email address from my colleague. We're trying to understand the following method:
setValidationScheme<https://xerces.apache.org/xerces-c/apiDocs-3/classSAXParser.html#ac8aec6a77c18efccbf799123311047d1>

This method allows users to set the validation scheme to be used by this parser.

The value is one of the ValSchemes enumerated values defined by this class:

Val_Never - turn off validation
Val_Always - turn on validation
Val_Auto - turn on validation if any internal/external DTD subset have been seen

The parser's default state is: Val_Never.
Parameters
newScheme
The new validation scheme to use.

We found that if we set this to Val_Always, the name space and the xsd location are required in the data. Here is an example:
Xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema version="1.1.0">
               <xs:element name="ITS" type="ITS"/>
               <xs:complexType name="ITS">
                              <xs:sequence>
                                             <xs:element name="Header" type="xs:string" minOccurs="1" maxOccurs="1"/>
                              </xs:sequence>
               </xs:complexType>
</xs:schema>

Xml Data:
<?xml version="1.0"?>
<ITS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=<http://www.w3.org/2001/XMLSchema-instance"%20xsi:noNamespaceSchemaLocation=>"ITS.xsd" >
<Header>NIL</Header>
</ITS>

After calling setValidationScheme with Val_Always, the highlighted attributes in the data are required to pass the validation, while calling with Val_Never, the highlighted attributes can be removed without causing the validation failure.
Is it OK to set to Val_Never in this case?

Thanks in advance,
Yan Zhang


________________________________

This electronic message, as well as any transmitted files included in the electronic message, may contain privileged or confidential information and is intended solely for the use of the individual(s) or entity to which it is addressed. If you have received this electronic message in error please notify the sender immediately and delete the electronic message. Any unauthorized copying, disclosure or distribution of the electronic message is strictly forbidden. NAV CANADA accepts no liability for any damage caused by any virus and/or other malicious code transmitted by this electronic communication.

Le pr?sent message ?lectronique et tout fichier qui peut y ?tre joint peuvent contenir des renseignements privil?gi?s ou confidentiels destin?s ? l'usage exclusif des personnes ou des organismes ? qui ils s'adressent. Si vous avez re?u ce message ?lectronique par erreur, veuillez en informer l'exp?diteur imm?diatement et supprimez le. Toute reproduction, divulgation ou distribution du pr?sent message ?lectronique est strictement interdite. NAV CANADA n'assume aucune responsabilit? en cas de dommage caus? par tout virus ou autre programme malveillant transmis par ce message ?lectronique.


More information about the xsd-users mailing list