locked
need XSLT help RRS feed

  • Question

  • Need help in writing XSLT.

    below is my source schema structure...

    I need to loop through the Orders/Order and if orderId matches with any of the OrderStatus/OrderId i need to select that orderIn destination.

    eh

    Saturday, July 23, 2016 6:31 PM

Answers

  • Hi Ammu,

    Here is one of the simple format to get the matching Orders using XSLT.

    - Update with your XPath.

      <xsl:template name="MatchingOrderID">
    
        <xsl:for-each select="/*[local-name()='OrderDetails' and namespace-uri()='http://MSDN']/*[local-name()='Orders' and namespace-uri()='']/*[local-name()='OrderStatus' and namespace-uri()='']">
          <xsl:variable name="OrderStatusID" select="./*[local-name()='OrderId' and namespace-uri()='']"/>
    
          <xsl:for-each select="/*[local-name()='OrderDetails' and namespace-uri()='http://MSDN']/*[local-name()='Orders' and namespace-uri()='']/*[local-name()='Order' and namespace-uri()='']">
            <xsl:variable name="OrderID" select="./*[local-name()='OrderId' and namespace-uri()='']"/>
    
            <xsl:if test="$OrderStatusID=$OrderID">
              <xsl:copy-of select="."/>
            </xsl:if>
    
          </xsl:for-each>
    
        </xsl:for-each>
    
      </xsl:template>


    Thanks, SMSViksaK

    • Proposed as answer by SMSVikasKEditor Friday, July 29, 2016 12:30 PM
    • Marked as answer by Angie Xu Tuesday, August 2, 2016 6:11 AM
    Sunday, July 24, 2016 9:55 AM
    Answerer

All replies

  • Hi Ammu,

    Here is one of the simple format to get the matching Orders using XSLT.

    - Update with your XPath.

      <xsl:template name="MatchingOrderID">
    
        <xsl:for-each select="/*[local-name()='OrderDetails' and namespace-uri()='http://MSDN']/*[local-name()='Orders' and namespace-uri()='']/*[local-name()='OrderStatus' and namespace-uri()='']">
          <xsl:variable name="OrderStatusID" select="./*[local-name()='OrderId' and namespace-uri()='']"/>
    
          <xsl:for-each select="/*[local-name()='OrderDetails' and namespace-uri()='http://MSDN']/*[local-name()='Orders' and namespace-uri()='']/*[local-name()='Order' and namespace-uri()='']">
            <xsl:variable name="OrderID" select="./*[local-name()='OrderId' and namespace-uri()='']"/>
    
            <xsl:if test="$OrderStatusID=$OrderID">
              <xsl:copy-of select="."/>
            </xsl:if>
    
          </xsl:for-each>
    
        </xsl:for-each>
    
      </xsl:template>


    Thanks, SMSViksaK

    • Proposed as answer by SMSVikasKEditor Friday, July 29, 2016 12:30 PM
    • Marked as answer by Angie Xu Tuesday, August 2, 2016 6:11 AM
    Sunday, July 24, 2016 9:55 AM
    Answerer
  • Hi,

    You can easily do this without XSLT and by using looping and equal to functoid.

    Try this approach as well:

    Order-------- Looping funtoid ---desniation unbounded node  for order

    Orderid  from first part of msg----- EqualTo Functoid1------- desniation unbounded node for order

    Orderid  from 2nd part of msg----- EqualTo Functoid1------- desniation unbounded node for order


    Regards Pushpendra K Singh

    Monday, July 25, 2016 8:46 PM
  • Hi,

    Using out of box functoids Logical Existance and Value Mapping, you can achieve this functionality. Try to avoid the custom XSLT since this will become element specific and code maintainability will be difficult, you can map it similar like below.

    Hope this Helps!!!!

    Please Mark as Answered If you are satisfy with Reply.

    • Proposed as answer by vikas.a.mehta Tuesday, July 26, 2016 9:39 AM
    Tuesday, July 26, 2016 9:39 AM
  • Hi Ammu_Biz,

    The implementation for the same is very simple using map.

    You just need to implement the concept called Conditional looping. Please  refer to below posted link for the sample of conditional looping. So for the part of the mapping which you are expecting to do from xslt can be easily done using the looping, equals and value mapping functoid.

    Conditional Looping

    Regards,


    Mandar Dharmadhikari

    Tuesday, July 26, 2016 10:02 AM
    Moderator