Xml 针对多个 xsd 的验证
Xml validation against multiple xsd
在 Spring 集成管道中,我们目前使用验证过滤器根据特定 xsd 模式验证 xml 消息。
<int-xml:validating-filter schema-location=classpath:/a.xsd />
当 xml 只有一个架构时,它工作正常。当存在多个模式时最好的方法是什么 xml 应该被验证?
例如
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn1" xsi:schemaLocation="urn1 urn1.xsd">
<Hdr>
</Hdr>
<Pyld>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn2" xsi:schemaLocation="urn2 urn2.xsd">
</Document>
</Pyld>
您错过了一个事实,即有一个可供配置的替代属性 <int-xml:validating-filter>
:
<xsd:attribute name="xml-validator" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Reference to a custom 'org.springframework.xml.validation.XmlValidator' strategy
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.xml.validation.XmlValidator"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
有了它,您已经可以提供多个 XSD 资源以包含在验证中。有关详细信息,请参阅 XmlValidatorFactory
。
在 Spring 集成管道中,我们目前使用验证过滤器根据特定 xsd 模式验证 xml 消息。
<int-xml:validating-filter schema-location=classpath:/a.xsd />
当 xml 只有一个架构时,它工作正常。当存在多个模式时最好的方法是什么 xml 应该被验证?
例如
<Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn1" xsi:schemaLocation="urn1 urn1.xsd">
<Hdr>
</Hdr>
<Pyld>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn2" xsi:schemaLocation="urn2 urn2.xsd">
</Document>
</Pyld>
您错过了一个事实,即有一个可供配置的替代属性 <int-xml:validating-filter>
:
<xsd:attribute name="xml-validator" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Reference to a custom 'org.springframework.xml.validation.XmlValidator' strategy
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.xml.validation.XmlValidator"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
有了它,您已经可以提供多个 XSD 资源以包含在验证中。有关详细信息,请参阅 XmlValidatorFactory
。