XSL Policy is not passing on the value in the outputVariable

Not applicable

I have an XSL policy which receives an incoming SOAP request and adds a tag into the SOAP Header. I am specifying a specific variable to accept the end product of the XSL transformation. However, That variable shows as empty int he trace logs when I consume it using an Assign Message (or Extract policy)

The XSL adds a sessionId to the incoming request.

XSL -

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    version="1.0" 
    xmlns:urn="urn:enterprise.soap.sforce.com" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" />
	<xsl:param name="sessionId"/>
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>


	<xsl:template match="soapenv:Header">
          <xsl:copy>
            <urn:sessionId>
            <xsl:value-of select="$sessionId"/>
            </urn:sessionId>
          </xsl:copy>
        </xsl:template>
</xsl:stylesheet>

XSL Policy -

<XSL name="XSLTransform">
    <DisplayName>XSLTransform</DisplayName>
    <Source>request</Source>
    <ResourceURL>xsl://AddSessionId.xslt</ResourceURL>
    <Parameters>
      <Parameter name="sessionId" ref="sessionId"/>
  </Parameters>
    <OutputVariable>IncomingRequest</OutputVariable>
</XSL> 

'IncomingRequest' is being consumed by an Assign Message policy - but the trace does not show this variable having any value. IncomingRequest.content is also empty.

Why is this happening?

Solved Solved
1 5 683
1 ACCEPTED SOLUTION

Hi @hari.vr-ext,

When you trace the XSL policy, do you see the IncomingRequest variable being set? In the Variables Assigned section of the trace, if you see IncomingRequest shown with an equals sign, then the value is being set, but maybe it is being set to an empty string. OutputVariable should be a string variable, not a message variable, so IncomingRequest.content would never have a value.

I tried an XSL policy on my system with OutputVariable and it worked. Maybe your XSL isn't generating any output for your input somehow? If you create a simpler XSL, does it work?

<XSL name="xslTest">
    <ResourceURL>xsl://TestScript.xslt</ResourceURL>
    <OutputVariable>testXslVar</OutputVariable>
</XSL>


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
                  <xsl:template match="/"><root/></xsl:template>
</xsl:stylesheet>

View solution in original post

5 REPLIES 5

Hi @hari.vr-ext,

When you trace the XSL policy, do you see the IncomingRequest variable being set? In the Variables Assigned section of the trace, if you see IncomingRequest shown with an equals sign, then the value is being set, but maybe it is being set to an empty string. OutputVariable should be a string variable, not a message variable, so IncomingRequest.content would never have a value.

I tried an XSL policy on my system with OutputVariable and it worked. Maybe your XSL isn't generating any output for your input somehow? If you create a simpler XSL, does it work?

<XSL name="xslTest">
    <ResourceURL>xsl://TestScript.xslt</ResourceURL>
    <OutputVariable>testXslVar</OutputVariable>
</XSL>


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
                  <xsl:template match="/"><root/></xsl:template>
</xsl:stylesheet>

HI @mdunker@apigee.com

I have the same problem as @hari.vr-ext. I even tested with your XSL and XSLT. I don't have assign message policy. I am expecting the value of testXslVar will be "<root/>". In trace I can see the variable testXslVar with no value after execution of the XSL policy. Also I added a javascript policy to print the variable using the code print(context.getVariable("testXslVar")); and it printed null value. Is there anything i am missing?

Thanks,

Krish


Hi Krish, for new questions, please Ask a new Question.

There's an "Ask a Question" button at the top.

4216-xsl-policy-is-not-passing-on-the-value-in-the-outp.png

Posted a new question. Thanks @Dino

Can you also show a simple example of the inbound soap request? Also, have you verified the XSL works outside of Apigee Edge? It should be pretty easy to run it on an example SOAP document to verify that it works the way you want it to.