Hi Aditya,
You need to add the local entry declaration in the registry inside your API
config. Without that, synapse does not know the location of your xsl. Refer
[1] for more details.

<localEntry key="xslt-key-req" src=
"file:repository/samples/resources/transform/transform.xslt"/>

[1] -
https://docs.wso2.com/display/EI611/Working+with+Local+Registry+Entries

Regards,
Vinod

On Mon, Jan 8, 2018 at 3:36 PM, aditya shivankar <
[email protected]> wrote:

> Hi,
>
> Thanks for the reply. But I am getting below error trying it. I think i am
> not able to configure xslt properly. followed online docs for configuring
> xslt in wso2 but still not able to. Could you please check my steps
> (attachment named "xsltTest_stepsFollowed.docx" )and correct me. Thanks.
>
>
> Error :
>
> [2018-01-08 15:19:35,020] [EI-Core]  WARN - SynapseConfigUtils Cannot
> convert null to a StreamSource
>
> [2018-01-08 15:19:35,020] [EI-Core] ERROR - XSLTMediator Error creating
> XSLT transformer using : Value {name ='null', keyValue ='transform'}
>
> *org.apache.synapse.SynapseException*: Cannot convert null to a
> StreamSource
>
>
>
> With Regards,
> Aditya
>
>
>
>
> On Sun, Jan 7, 2018 at 11:49 PM, Eranda Rajapakshe <[email protected]>
> wrote:
>
>> Hi Aditya,
>>
>> You can use XSLT mediator to achieve this, following is a sample
>> configuration I created.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>> <proxy xmlns="http://ws.apache.org/ns/synapse";
>>>        name="sample"
>>>        startOnLoad="true"
>>>        statistics="disable"
>>>        trace="disable"
>>>        transports="http,https">
>>>    <target>
>>>       <inSequence>
>>>          <property name="messageType" scope="axis2"
>>> value="application/json"/>
>>>          <xslt key="transform"/>
>>>          <respond/>
>>>       </inSequence>
>>>    </target>
>>>    <description/>
>>> </proxy>
>>
>>
>>
>>    <localEntry key="transform">
>>>         <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1
>>> 999/XSL/Transform">
>>>             <xsl:template match="/">
>>>                 <Childern>
>>>                     <xsl:for-each select="//Children">
>>>                         <xsl:element name="{Name/Value}">
>>>                             <xsl:value-of select="Education/Value"/>
>>>                         </xsl:element>
>>>                     </xsl:for-each>
>>>                 </Childern>
>>>             </xsl:template>
>>>         </xsl:stylesheet>
>>>         <description/>
>>>     </localEntry>
>>
>>
>>
>> Input will be following,
>>
>>
>>> {
>>> "Children": [
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Gayle"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "PostGraduate"
>>> }
>>> },
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Chris"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "Graduate"
>>> }
>>> },
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Steve"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "PostGraduate"
>>> }
>>> },
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Stephen"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "Graduate"
>>> }
>>> }
>>> ]
>>> }
>>
>>
>>
>> Output:
>>
>> {
>>>     "Childern": {
>>>         "Gayle": "PostGraduate",
>>>         "Chris": "Graduate",
>>>         "Steve": "PostGraduate",
>>>         "Stephen": "Graduate"
>>>     }
>>> }
>>
>>
>>
>> Thanks,
>>
>>
>> On Sun, Jan 7, 2018 at 6:23 PM, aditya shivankar <
>> [email protected]> wrote:
>>
>>> Respected Sir,
>>>
>>> I have response from one external service something like below,
>>> indicating children name and education.
>>> Each time i call this service with different input, it returns me few
>>> children( number of children returned could be different each time
>>> depending on my request data ).
>>>
>>>
>>> Service Response(which needs to be transformed)
>>> {
>>> "Children": [
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Gayle"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "PostGraduate"
>>> }
>>> },
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Chris"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "Graduate"
>>> }
>>> },
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Steve"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "PostGraduate"
>>> }
>>> },
>>> {
>>> "Name": {
>>> "Type": "System.String",
>>> "Value": "Stephen"
>>> },
>>> "Education":{
>>> "Type": "System.String",
>>> "Value": "Graduate"
>>> }
>>> }
>>> ]
>>> }
>>>
>>>
>>> Desired Output :
>>>
>>> {
>>> "Gayle": "PostGraduate",
>>> "Chris": "Graduate",
>>> "Steve": "PostGraduate",
>>> "Stephen": "Graduate"
>>> }
>>>
>>> I would  like to do this using PayloadFactory or Enrich component.
>>> I cannot use dataMapper,because the actual response from service is too
>>> big and dataMapper GUI hangs and also makes eclipsce to hang forever for
>>> such big jsons.
>>> Please guide.
>>>
>>> With Regards,
>>> Aditya
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> *Eranda Rajapakshe*
>> Software Engineer
>> WSO2 Inc.
>> Mobile : +94784822608
>>
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Vinod Kavinda
Senior Software Engineer
*WSO2 Inc. - lean . enterprise . middleware <http://www.wso2.com>.*
Mobile : +94 (0) 712 415544
Blog : http://soatechflicks.blogspot.com/
[image: http://wso2.com/signature]
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to