Topic
  • 10 replies
  • Latest Post - ‏2010-06-11T17:20:53Z by SystemAdmin
SystemAdmin
SystemAdmin
6089 Posts

Pinned topic What's preferred for Custom Transformation XPAth or XSLT or Java?

‏2010-03-23T23:41:16Z |
I think the transformation are resource intensice, I am working with a simple transformation I am just wondering which option should I choose for better performace as this is common accross many services. I can achieve this with XPath or XSLT or Java. The following is the sample request reply I am also enclosing the PI with XPath solution.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sig="http://SignMediation/SignedService">
<soapenv:Header/>
<soapenv:Body>
<sig:getSignedAmount>
<amount>100</amount>
<sign>D</sign>
</sig:getSignedAmount>
</soapenv:Body>
</soapenv:Envelope>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:se="http://SignMediation/SignedService">
<signedAmount>-100.0</signedAmount>
</se:getSignedAmountResponse>
</soapenv:Body>
</soapenv:Envelope>

If sign is D then signedAmount = signedAmount * -1 else just move the amount into signedAmount

Appreciate any thoughts as I will have some idea when I design bit more complex transformation

Regards,
Vijay
Updated on 2010-06-11T17:20:53Z at 2010-06-11T17:20:53Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6089 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-24T09:22:04Z  
    Hi,

    Interesting question. But with the size of xml data you showed here, you won't notice any difference. Which WebSphere version are you using? There are lots of information on this subject on the web. I found some stuff about XPath vs. XSLT very quickly:

    Xerces, the default XPath processor included with the Sun JDK, can be slow and uses a lot of memory if the xml data gets very large. Xerces is an open source XML processor developed by Apache.

    Xalan is an XSLT processor that uses Xerces to transform XML. WebSphere Application Server, at least Version 4.0x, ships with Xerces and Xalan. Xalan is not the fastest processor on the market.

    Br,
    Mats
  • SystemAdmin
    SystemAdmin
    6089 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-24T20:18:38Z  
    Hi,

    Interesting question. But with the size of xml data you showed here, you won't notice any difference. Which WebSphere version are you using? There are lots of information on this subject on the web. I found some stuff about XPath vs. XSLT very quickly:

    Xerces, the default XPath processor included with the Sun JDK, can be slow and uses a lot of memory if the xml data gets very large. Xerces is an open source XML processor developed by Apache.

    Xalan is an XSLT processor that uses Xerces to transform XML. WebSphere Application Server, at least Version 4.0x, ships with Xerces and Xalan. Xalan is not the fastest processor on the market.

    Br,
    Mats
    Thanks Mats for the response, please note that the actual XML is different from what I have shown here, I didn't want the client stuff on the web, also one XML potentially can have 50 to 500 or more tranformations of this type and this is C2B on the web so there may be huge transformations happening.
    Thank You.
    Vijay
  • SystemAdmin
    SystemAdmin
    6089 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-24T20:21:25Z  
    Hi,

    Interesting question. But with the size of xml data you showed here, you won't notice any difference. Which WebSphere version are you using? There are lots of information on this subject on the web. I found some stuff about XPath vs. XSLT very quickly:

    Xerces, the default XPath processor included with the Sun JDK, can be slow and uses a lot of memory if the xml data gets very large. Xerces is an open source XML processor developed by Apache.

    Xalan is an XSLT processor that uses Xerces to transform XML. WebSphere Application Server, at least Version 4.0x, ships with Xerces and Xalan. Xalan is not the fastest processor on the market.

    Br,
    Mats
    It's WID6.2 and the WebSphere is 6.1.0.21
  • kolban
    kolban
    518 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-24T22:25:56Z  
    It's WID6.2 and the WebSphere is 6.1.0.21
    I think IBM's recommended/strategic direction for all data transformations is XSLT.
  • spriet
    spriet
    58 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-25T01:48:05Z  
    Conditional logic like this is usually expressed in XPath. Each mapping as you have in your sample PI can have a condition so I would agree that this is the right solution for WID 6.2x product. I noticed that your Move has a condition but if you want the "else" semantics then you probably want this type of xpath $amount/../sign!="D"

    In WID V7 we have introduced the ability to do if/else if/else type mappings and you don't need the second condition.

    Dave Spriet
    Architect, Mapping and Transformation Tools, IBM
  • SystemAdmin
    SystemAdmin
    6089 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-27T10:42:32Z  
    • spriet
    • ‏2010-03-25T01:48:05Z
    Conditional logic like this is usually expressed in XPath. Each mapping as you have in your sample PI can have a condition so I would agree that this is the right solution for WID 6.2x product. I noticed that your Move has a condition but if you want the "else" semantics then you probably want this type of xpath $amount/../sign!="D"

    In WID V7 we have introduced the ability to do if/else if/else type mappings and you don't need the second condition.

    Dave Spriet
    Architect, Mapping and Transformation Tools, IBM
    Hi Dave,
    Thanks for the response. In your opinion what's recommended, when you can achieve a solution with all three options. Given XPath2.0 is more flexible and I think we can achieve even complex transformation using XPath Expression itself.
    Regards,
    Vijay
  • spriet
    spriet
    58 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-27T14:58:48Z  
    Hi Dave,
    Thanks for the response. In your opinion what's recommended, when you can achieve a solution with all three options. Given XPath2.0 is more flexible and I think we can achieve even complex transformation using XPath Expression itself.
    Regards,
    Vijay
    WID/WPS/WESB V62x and V7 do not support XSLT 2.0/XPath 2.0 so you can not use XPath 2.0 functions which are not in the XPath 1.0 function library.

    However, the best way to handle expressions within the XML Mapper(either filtering or conditional logic) is to always use XPath and in the majority of the cases XPath is the right solution. If you just can not express the logic in XPath (ie maybe the condition is just to complex to express using XPath 1.0) then you can then use either a custom XSL Template or a Java Extension function.

    If you have a choice between the two then go with XSL Templates but this would require knowledge of XSL programming but we do generate a XSL template when creating a "New" xslt template on the Custom XSLT mapping. If writing custom XSL is not your cup of tea then you can always opt out for using Java Extension functions.

    I hope this helps in making your decision. If you need any more clarifications please feel free to ask in this thread.

    Dave Spriet
    Architect, Mapping and Transformation Tools,IBM
  • SystemAdmin
    SystemAdmin
    6089 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-03-27T23:59:55Z  
    • spriet
    • ‏2010-03-27T14:58:48Z
    WID/WPS/WESB V62x and V7 do not support XSLT 2.0/XPath 2.0 so you can not use XPath 2.0 functions which are not in the XPath 1.0 function library.

    However, the best way to handle expressions within the XML Mapper(either filtering or conditional logic) is to always use XPath and in the majority of the cases XPath is the right solution. If you just can not express the logic in XPath (ie maybe the condition is just to complex to express using XPath 1.0) then you can then use either a custom XSL Template or a Java Extension function.

    If you have a choice between the two then go with XSL Templates but this would require knowledge of XSL programming but we do generate a XSL template when creating a "New" xslt template on the Custom XSLT mapping. If writing custom XSL is not your cup of tea then you can always opt out for using Java Extension functions.

    I hope this helps in making your decision. If you need any more clarifications please feel free to ask in this thread.

    Dave Spriet
    Architect, Mapping and Transformation Tools,IBM
    Hi Dave, Thanks for your really good input.
    Regards,
    Vijay
  • keetesh
    keetesh
    2 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-06-08T01:22:11Z  
    ****************
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sig="http://SignMediation/SignedService">
    ***************

    How could you customize <soapenv:Envelop to add xmlns:sig="http://SignMediation/SignedService, I'm using WAS v7.0 on WebSphere Commerce, is there any way to do it using Admin Console?
  • SystemAdmin
    SystemAdmin
    6089 Posts

    Re: What's preferred for Custom Transformation XPAth or XSLT or Java?

    ‏2010-06-11T17:20:53Z  
    When is XPath 2.0 going to be supported in WID v7?