如何访问int-xml:xslt-transformer标签的多个xsl资源?

时间:2014-03-14 11:31:19

标签: java spring xslt spring-integration

任何人都可以建议我如何使用int-xml:xslt-transformer标签访问多个xsl文件,我试过下面的代码,但它无法帮助我。

    

    <int-xml:xpath-router id="responderRouter" input-channel="PQGetGroupMainScreen-Amisys-Channel">
        <int-xml:xpath-expression expression="/GroupMainRequest/GroupId"/>
        <int-xml:mapping value="Move" channel="items"/>
         <int-xml:mapping value="Loan" channel="parameters"/>
    </int-xml:xpath-router>

    <int-xml:xslt-transformer input-channel="items" xsl-resource="${stylesheet.amisys.soaXml.PQGetGroupMainScreen}"  /> 

    <int-xml:xslt-transformer input-channel="parameters" xsl-resource="${stylesheet.amisys.soaXml.PQGetGroupMainScreenShow}"  /> 

    <int:service-activator  ref="httpOutboundGatewayHandler" method="buildHttpOutboundGatewayRequest" />

    <int-http:outbound-gateway  url-expression="headers.restResourceUrl"
                                http-method-expression="headers.httpMethod"
                                expected-response-type="java.lang.String" >
    </int-http:outbound-gateway>

</int:chain>

配置完成后,当我执行junit测试用例时,下面是我在控制台中遇到的错误,请任何人帮我解决这个问题。

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [spring-integration/Jobs/*.xml]
Offending resource: class path resource [CustomerService/JobDesigner-springintegration.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: The 'input-channel' attribute isn't allowed for a nested (e.g. inside a <chain/>) endpoint element: 'int-xml:xpath-router' with id='responderRouter'.
Offending resource: file [D:\New CSWorkspace\CustomerService\csServer\target\test-classes\CustomerService\spring-integration\Jobs\PQGetGroupMainScreen.xml]
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:271)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:196)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:181)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:255)
    ... 42 more

1 个答案:

答案 0 :(得分:1)

看起来你正在使用spring集成框架。你应该在发布问题时提供所有信息。看来你的配置是这样的:

<int:chain> 
<int-xml:xpath-router id="responderRouter" input-channel="PQGetGroupMainScreen-Amisys-Channel">
        <int-xml:xpath-expression expression="/GroupMainRequest/GroupId"/>
        <int-xml:mapping value="Move" channel="items"/>
         <int-xml:mapping value="Loan" channel="parameters"/>
    </int-xml:xpath-router>

    <int-xml:xslt-transformer input-channel="items" xsl-resource="${stylesheet.amisys.soaXml.PQGetGroupMainScreen}"  /> 

    <int-xml:xslt-transformer input-channel="parameters" xsl-resource="${stylesheet.amisys.soaXml.PQGetGroupMainScreenShow}"  /> 

    <int:service-activator  ref="httpOutboundGatewayHandler" method="buildHttpOutboundGatewayRequest" />

    <int-http:outbound-gateway  url-expression="headers.restResourceUrl"
                                http-method-expression="headers.httpMethod"
                                expected-response-type="java.lang.String" >
    </int-http:outbound-gateway>

</int:chain>

路由器只能作为链的最后一个组件存在。有关信息,请参阅https://jira.spring.io/browse/INT-1066

根据例外情况,您应该将其更改为以下内容

  <int-xml:xpath-router id="responderRouter" input-channel="PQGetGroupMainScreen-Amisys-Channel" ouput-channel="chain">
            <int-xml:xpath-expression expression="/GroupMainRequest/GroupId"/>
            <int-xml:mapping value="Move" channel="items"/>
             <int-xml:mapping value="Loan" channel="parameters"/>
        </int-xml:xpath-router>

 <int:chain input-channel="chain> 

        <int-xml:xslt-transformer  xsl-resource="${stylesheet.amisys.soaXml.PQGetGroupMainScreen}"  /> 

        <int-xml:xslt-transformer  xsl-resource="${stylesheet.amisys.soaXml.PQGetGroupMainScreenShow}"  /> 

        <int:service-activator  ref="httpOutboundGatewayHandler" method="buildHttpOutboundGatewayRequest" />

        <int-http:outbound-gateway  url-expression="headers.restResourceUrl"
                                    http-method-expression="headers.httpMethod"
                                    expected-response-type="java.lang.String" >
        </int-http:outbound-gateway>

    </int:chain>

规则:您不应为链内的组件指定输入/输出通道。它们应在链本身上指定。