XSL policy not generating/transforming xml payload into expected resultant xml payload

 
Hi all,
I have created simple XSL policy to transform XML payload into another XML payload.
but not getting expected result in Apigee edge
XSL policy-->

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- Identity template to copy elements as is -->
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>

  <!-- Template to handle phone elements -->
  <xsl:template match="*[contains(local-name(), 'Phone') and not(starts-with(local-name(), 'phone'))]">
    <xsl:copy>
      <countryCode></countryCode>
      <subscriberNumber>
        <xsl:value-of select="."/>
      </subscriberNumber>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

 

Input--->

 

<sml>
	<sml>
		<dayPhone>9090909091</dayPhone>
	</sml>
	<BusinessPhoneNumber/>
	<phonePin/>
</sml>

 

 
expected--->

 

<sml>
	<sml>
		<dayPhone>
			<countryCode/>
			<subscriberNumber>9090909091</subscriberNumber>
		</dayPhone>
	</sml>
	<BusinessPhoneNumber>
		<countryCode/>
		<subscriberNumber/>
	</BusinessPhoneNumber>
	<phonePin/>
</sml>

 

Actual-->

 

<sml>
	<sml>
		<dayPhone>9090909091</dayPhone>
	</sml>
	<BusinessPhoneNumber/>
	<phonePin/>
</sml>

 

when I am trying with other XSL processing tool its giving expected result,
with Apigee edge I am not getting expected result
-------------------------------------------------------------------------------------------------------------------------------------
If XML key is like phone at any position except start, I want it to get converted into other format.
added 3 examples below for better clarification
 
1] In key phone is at end so needs to convert

 

<dayPhone>9090909091</dayPhone>
expected conversion-->
<dayPhone>
	<countryCode/>
	<subscriberNumber>9090909091</subscriberNumber>
</dayPhone>

 

 
2] In key phone is at middle so needs to convert

 

<BusinessPhoneNumber/>
expected conversion-->
<BusinessPhoneNumber>
	<countryCode/>
	<subscriberNumber/>
</BusinessPhoneNumber>

 

 
3] In key phone is at start so no need of conversion

 

<phonePin/>
expected no conversion-->
<phonePin/>

 

@dchiesa1  @omidt Is there anything I am missing here.

 

Solved Solved
1 2 247
2 ACCEPTED SOLUTIONS

After a bit of digging, I was able to find a small error that resolved the problem and made it function properly.

When I built the policy and added it to the response flow, by default the source of the payload  was set to<Source>request</Source>.

I modified it to <Source>response</Source>  now its working

View solution in original post

Well done for cracking it in the end and thank you for reporting back here!

View solution in original post

2 REPLIES 2

After a bit of digging, I was able to find a small error that resolved the problem and made it function properly.

When I built the policy and added it to the response flow, by default the source of the payload  was set to<Source>request</Source>.

I modified it to <Source>response</Source>  now its working

Well done for cracking it in the end and thank you for reporting back here!