Skip to Content
0
Former Member
May 22, 2009 at 11:27 AM

XSLT Transformation

22 Views

Hi,

I have following XML: I cut it a bit because it's too long for this thread.


<?xml version="1.0" encoding="windows-1252"?>
<OpenShipments xmlns="x-schema:OpenShipments.xdr">
	<OpenShipment ProcessStatus="Processed" ShipmentOption="">
		<ProcessMessage>	
			<TrackingNumbers>
				<TrackingNumber>1</TrackingNumber>
				<TrackingNumber>2</TrackingNumber>
				<TrackingNumber>3</TrackingNumber>
			</TrackingNumbers>
			<ImportID>P5</ImportID>
			<Reference1>P1</Reference1>
			<Reference2>P2</Reference2>
		</ProcessMessage>
	</OpenShipment>
</OpenShipments>

and this is my transformation:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pre="x-schema:OpenShipments.xdr" version="1.0">

  <xsl:template match="*">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
      <asx:values>

        <ROOT>

          <LIST>

            <xsl:for-each select="/pre:OpenShipments/pre:OpenShipment/pre:ProcessMessage/pre:TrackingNumbers">

              <item>

                <TRACKINGNUMBER>
                  <xsl:value-of select="string(pre:TrackingNumber)"/>
                </TRACKINGNUMBER>

              </item>
            </xsl:for-each>

          </LIST>

        </ROOT>

      </asx:values>
    </asx:abap>
  </xsl:template>

</xsl:transform>

So the problem is that my loop (for each) is based on TrackingNumbers and within this part I have 3 elements which have the same indication. So after my for each part I get only the first value of trackingnumber. So is there any expression which I can use that I get all 3 items?