针对多个xsd



在Spring Integration管道中,我们目前使用验证过滤器来根据特定的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

相关内容

  • 没有找到相关文章

最新更新