Announcement Announcement Module
Collapse
No announcement yet.
XPath/XSLT Conflict Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • XPath/XSLT Conflict

    Hi all. I'm attempting to create a Spring Integration flow involving an xpath-header-enricher and an xslt-transformer. The transformer works fine on its own, as does the header enricher. However, once I follow the header enricher with the transformer, I get a "failed to transform"/"content is not allowed in prolog" error.

    That error is usually indicative of malformed XML somewhere or an encoding issue, but when the transformation works perfectly on its own, I can't possibly imagine that a header enricher would affect the payload (which is a Document) at all, let alone to the point where it would break it.

    This leads me to believe that using the xpath-header-enricher introduces a parser which doesn't play nice with the transformer. I have Saxon as a dependency so I can use XSLT 2.0. I looked into the hierarchy and saw that Jaxen is an optional dependency to spring-xml (the WS version), but including it in my project didn't change anything.

    Any ideas? Here's my configuration:

    Code:
    <int:gateway service-interface="com.domain.framework.event.gateway.EventGateway"
    	id="eventGateway" default-request-channel="eventRouteAccessChainChannel"
    	default-reply-channel="eventGatewayOutputChannel" />
    
    <int-xml:xpath-expression id="eventTypeExp"
    	expression="/emit:event/@eventType" namespace-map="namespaceMap" />
    
    <int:chain input-channel="eventRouteAccessChainChannel">
    	<int-xml:validating-filter schema-location="classpath:schemas/emitterEvent.xsd"
    		discard-channel="eventErrorChannel" />
    	<int-xml:xpath-header-enricher>
    		<int-xml:header name="eventType" xpath-expression-ref="eventTypeExp" />
    		<int-xml:header name="eventAll" xpath-expression="/" />
    	</int-xml:xpath-header-enricher>
    	<int:router default-output-channel="eventErrorChannel"
    		expression="headers.eventType + 'RulesChannel'" />
    </int:chain>
    
    <int:service-activator input-channel="testRulesChannel"
    	output-channel="eventRouteChainChannel" expression="@routingMap.get(headers.eventType)" />
    
    <int:chain input-channel="eventRouteChainChannel"
    	output-channel="eventGatewayOutputChannel">
    	<int:splitter expression="payload" />
    	<int:header-enricher>
    		<int:header name="eventRoute" expression="payload" />
    	</int:header-enricher>
    	<int:service-activator expression="headers.eventAll" />
    	<int-xml:xslt-transformer xsl-resource="xsl/emitterEvent-to-event-transformer.xsl" />
    </int:chain>
    I have wiretaps on my channels so I can see that my message is definitely passing through the flow, as it gets the correct headers/payload based on the other components.

    Thanks.

  • #2
    Can you run with DEBUG level logging and compare the inbound message to the transformer on the works Vs. not works scenario?

    Comment


    • #3
      Hi, Matt!

      So, I see where is a problem.
      I minimize your config to show it:
      HTML Code:
      <int-xml:xpath-header-enricher>
      	<int-xml:header name="eventAll" xpath-expression="/" /> !!! HERE !!!
      </int-xml:xpath-header-enricher>
      <int:service-activator expression="headers.eventAll" />
      <int-xml:xslt-transformer xsl-resource="xsl/emitterEvent-to-event-transformer.xsl" />
      By default <xml:header> will be converted to the String, because:
      <xsd:attribute name="evaluation-type" default="STRING_RESULT">
      So to fix your issue, just to make it like this:
      HTML Code:
      <int-xml:header name="eventAll" xpath-expression="/" evaluation-type="NODE_RESULT"/>
      Take care,
      Artem

      Comment


      • #4
        Thanks, Artem. That worked. I also found that I could have used a regular header enricher with an expression of "payload" to get the same result, but I'm going with your idea so I can group all the headers I'm adding together.

        Thanks again!

        Comment

        Working...
        X