processContents strict vs lax vs skip for xsd:any

后端 未结 1 483
我寻月下人不归
我寻月下人不归 2020-11-27 06:59

master.xsd:




        
相关标签:
1条回答
  • 2020-11-27 07:19

    Because the XSD specifies

    <any processContents="strict" />
    

    in the content model of aspect, your XML is invalid due to processContents="strict", which requires that the XML processor must be able to obtain the XSD definition for, in this case, security and must be able to validate it.

    If you change this to

    <any processContents="lax" />
    

    your XML will be valid, and if you come to define security in your XSD, the definition will be used during validation. (If the definition cannot be found, your document will still be considered to be valid.) This requires that the content be valid only if XML processor can find its definition.

    If you change this to

    <any processContents="skip" />
    

    your XML will be valid and the XML processor will make no attempt to validate the children content under aspect (other than that requiring it to be some single element per the sequence constraint).

    Notes:

    • The default value for processContents is strict.
    • See section 3.10.2 XML Representation of Wildcard Schema Components in the XSD Recommendation for more information.
    • If you're wondering about how to bring another XSD into your master XSD, see xsd:import vs xsd:include.
    0 讨论(0)
提交回复
热议问题