Can I create an XSD schema that places an attribute on all complex types?

前端 未结 4 939
日久生厌
日久生厌 2021-01-06 14:02

I would like to create an XSD that defines an attribute which can be placed on elements from other schemas, or elements that are not in any schema. For example, the schema

4条回答
  •  旧时难觅i
    2021-01-06 14:42

    This is exactly what NVDL (Namespace-based Validation and Dispatching Language) provides. It allows to combine multiple schemas/vocabularies to validate a document without the need to change those schemas. NVDL is an ISO standard.

    A working NVDL script that handles your case is below

    
      
        
          
        
      
      
        
          
        
      
    
    

    Basically it says validate what it is on the ...tempuri.org/OtherSchema namespace with the other.xsd schema and the attributes from ...tempuri.org/MySchema with the my.xsd schema.

    For more info about NVDL see www.nvdl.org. The above script was tested with oNVDL.

提交回复
热议问题