0 Replies Latest reply: Apr 10, 2012 8:15 AM by 809315 RSS

    XSLT Help On Loop

    809315
      I have an array of 2 stops that I am looping over. Each element can have multiple orders. When I map to the target there is only 1 place to put orders per stop. So I want to loop over all of the orders and concatenate them with a "|" in 1 field on the target. So the input looks like this.

      <ns1:stops>
           <ns1:plannedArrival>2012-04-09T14:18:28.0000000</ns1:plannedArrival>
           <ns1:orders>
                <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
                     <ns1:orderNumber>S2O1</ns1:orderNumber>
                </ns1:orderIdentity>
           </ns1:orders>
           <ns1:orders>
                <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
                     <ns1:orderNumber>S2O2</ns1:orderNumber>
                </ns1:orderIdentity>
           </ns1:orders>
           <ns1:orders>
                <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
                     <ns1:orderNumber>S2O3</ns1:orderNumber>
                </ns1:orderIdentity>
           </ns1:orders>
           <ns1:removeFlag>false</ns1:removeFlag>
      </ns1:stops>
      <ns1:stops>
           <ns1:plannedArrival>2012-04-09T15:19:39.0000000</ns1:plannedArrival>
           <ns1:orders>
                <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
                     <ns1:orderNumber>S3O1</ns1:orderNumber>
                </ns1:orderIdentity>
           </ns1:orders>
           <ns1:orders>
                <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
                     <ns1:orderNumber>S3O2</ns1:orderNumber>
                </ns1:orderIdentity>
           </ns1:orders>
           <ns1:orders>
                <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
                     <ns1:orderNumber>S3O3</ns1:orderNumber>
                </ns1:orderIdentity>
           </ns1:orders>
           <ns1:removeFlag>false</ns1:removeFlag>
      </ns1:stops>


      The target is coming out like this. With an element for each one in the loop
      <ns0:Detail>
      <ns0:OrderNumber>S1O1</ns0:OrderNumber>
      <ns0:OrderNumber>S1O2</ns0:OrderNumber>
      <ns0:OrderNumber>S1O3</ns0:OrderNumber>
      <ns0:OrderNumber>S1O4</ns0:OrderNumber>
      <ns0:OrderNumber>S1O5</ns0:OrderNumber>
      </ns0:Detail>

      I want it to look like this
      <ns0:Detail>
      <ns0:OrderNumber>S1O1|S1O2|S1O3|S1O4|S1O5</ns0:OrderNumber>
      </ns0:Detail>


      Here is the XSLT that gives the bad one.

      <xsl:for-each select="ns1:orders">
      <ns0:OrderNumber>
      <xsl:value-of select="ns1:orderIdentity/ns1:orderNumber"/>
      </ns0:OrderNumber>
      </xsl:for-each>


      How do I change this?