How to read context variables in xsl

Not applicable

I know how to read environment.name values in javascript. But how to do this in xsl?

Solved Solved
1 4 2,320
1 ACCEPTED SOLUTION

akoo
New Member
You can pass in variables to XSLT from Apigee run-time flow. There are 2 parts to this:
  1. In your XSLT-calling policy, include the following tags:
    <Parameters ignoreUnresolvedVariables="true" >
      <Parameter name="XSLT.environment.name" ref="environment.name"/>
    </Parameters>

2. Within the XSL file itself, include the following tags to reference the variable you are passing in:

<xsl:param name="XSLT.environment.name"/>

<test><xsl:value-of select="$XSLT.environment.name"/></test>

View solution in original post

4 REPLIES 4

akoo
New Member
You can pass in variables to XSLT from Apigee run-time flow. There are 2 parts to this:
  1. In your XSLT-calling policy, include the following tags:
    <Parameters ignoreUnresolvedVariables="true" >
      <Parameter name="XSLT.environment.name" ref="environment.name"/>
    </Parameters>

2. Within the XSL file itself, include the following tags to reference the variable you are passing in:

<xsl:param name="XSLT.environment.name"/>

<test><xsl:value-of select="$XSLT.environment.name"/></test>

Thanks that worked for environment.variable

I tried similarly for query param as well in preflow response of proxy endpoint. I need to read queryparam from the incoming request and populate in one of the element of the response.

But the source for the xmlTransform is response

<Source>response</Source>
<Parameter name="XSLT.queryparam.title" ref="request.queryparam.title"/>

and use this parameter in stylesheet.

But this gave an empty value.

I got it done in the following way.

In the request javascript, I set the queryparam to context variable and referred that variable in xsl transform.

Is there any other way we can call directly the request queryparam in response xsl transform

@satishbabu.kodali according to the docs ( http://apigee.com/docs/api-services/reference/variables-reference ) the scope of request.queryparam is request side only, which would explain why you got empty value on the response side. I think the way you solved it is best, capture as a flow variable on the request side, and reference that variable on the response side.