0

I am attempting to transform the following SOAP response:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <GetSellerListResponse xmlns="urn:ebay:apis:eBLBaseComponents">
   <Timestamp>2016-09-26T08:56:24.441Z</Timestamp>
   <Ack>Success</Ack>
   <Version>979</Version>
   <Build>E979_CORE_API_18061413_R1</Build>
   <PaginationResult>
    <TotalNumberOfEntries>3</TotalNumberOfEntries>
   </PaginationResult>
   <ItemArray>
    <Item>
     <ItemID>110183939099</ItemID>
     <ListingDetails>
      <StartTime>2016-09-21T15:24:07.000Z</StartTime>
      <EndTime>2016-09-28T15:24:07.000Z</EndTime>
     </ListingDetails>
    </Item>
    <Item>
     <ItemID>110183939198</ItemID>
     <ListingDetails>
      <StartTime>2016-09-21T15:29:50.000Z</StartTime>
      <EndTime>2016-09-28T15:29:50.000Z</EndTime>
     </ListingDetails>
    </Item>
   </ItemArray>
   <ReturnedItemCountActual>3</ReturnedItemCountActual>
  </GetSellerListResponse>
 </soapenv:Body>
</soapenv:Envelope>

I have attempted to transform using the following XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//ItemArray"><xsl:text>&#xa;</xsl:text>
<entries entity="Product" action="import"><xsl:text>&#xa;</xsl:text>
<xsl:for-each select="Item">
<entry externalReference="{ItemID}" thirdPartyReference="{ItemID}"/><xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</entries>
</xsl:template>
</xsl:stylesheet>

This is what I want the result of the transform to be:

<?xml version="1.0" encoding="UTF-8"?>
<entries entity="Product" action="import">
<entry externalReference="110183876099" thirdPartyReference="110183876099"/>
<entry externalReference="110183876188" thirdPartyReference="110183876188"/>
</entries>

But currently it outputs like this:

<?xml version="1.0" encoding="UTF-8"?>


   2016-09-26T08:56:24.441Z
   Success
   979
   E979_CORE_API_18061413_R1

    2



     110183876099

      2016-09-21T15:24:07.000Z
      2016-09-28T15:24:07.000Z



     110183876188

      2016-09-21T15:29:50.000Z
      2016-09-28T15:29:50.000Z



   2

What am I doing wrong here in my XSLT formating to not get the desired output?

crmepham
  • 4,676
  • 19
  • 80
  • 155

1 Answers1

1

Problem: Missmatch of namespaces in expressions

See Thread: Use of XSLT namespaces

Solution:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bl="urn:ebay:apis:eBLBaseComponents" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    exclude-result-prefixes="xsl bl soapenv">

    <xsl:template match="/">
        <xsl:apply-templates select="soapenv:Envelope/soapenv:Body/bl:GetSellerListResponse/bl:ItemArray"/>
    </xsl:template>

    <xsl:template match="bl:ItemArray"><xsl:text>&#xa;</xsl:text>
        <entries entity="Product" action="import"><xsl:text>&#xa;</xsl:text>
            <xsl:for-each select="bl:Item">
                <entry externalReference="{bl:ItemID}" thirdPartyReference="{bl:ItemID}"/><xsl:text>&#xa;</xsl:text>
            </xsl:for-each>
        </entries>
    </xsl:template>
</xsl:stylesheet>
Community
  • 1
  • 1
uL1
  • 2,117
  • 2
  • 17
  • 28