Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

spring integration - Xml validation against multiple xsd

In Spring Integration pipeline we currently use the validating filter to validate xml message against a certain xsd schema.

<int-xml:validating-filter schema-location=classpath:/a.xsd />

It works fine when the xml has just one schema. What is the best approach when there are multiple schemas against which the xml should be validated?

E.g.

<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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You missed the fact that there is an alternative attribute to configure for that <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>

And with that one you already can provide several XSD resource to include into validation. See a XmlValidatorFactory for more info.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...