Transforming xsl with namespaces

I'm having some trouble trying to transform this XML:

 <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
   <p:GetAgendamento xmlns:p="http://ws.wso2.org/dataservice">
    <xs:Servico xmlns:xs="http://ws.wso2.org/dataservice">1</xs:Servico>
    <xs:Oportunidade xmlns:xs="http://ws.wso2.org/dataservice">2</xs:Oportunidade>
    <xs:Caso xmlns:xs="http://ws.wso2.org/dataservice">3</xs:Caso>
   </p:GetAgendamento>
  </soapenv:Body>
</soapenv:Envelope>

to this:

<GetAppointment>
  <ServiceOrderID>1</ServiceID>
  <OpportunityID>2</OpportunityID>
  <CaseID>3</CaseID>
</GetAppointment>

But, using a tool that generate this xsl:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:p="http://ws.wso2.org/dataservice" version="2.0" xpath-default-namespace="http://www.algartelecom.com.br/SOA/Service/GetAppointmentSchedulePortalReqCS">
  <xsl:output method="xml" indent="yes" />
  <xsl:template match="p:GetAgendamento">
    <GetAppointment>
      <xsl:call-template name="_template_0" />
    </GetAppointment>
  </xsl:template>
  <xsl:template name="_template_0">
    <xsl:for-each select="xs:Servico">
      <ServiceOrderID>
        <xsl:apply-templates select="." />
      </ServiceOrderID>
    </xsl:for-each>
    <xsl:for-each select="xs:Oportunidade">
      <OportunityID>
        <xsl:apply-templates select="." />
      </OportunityID>
    </xsl:for-each>
    <xsl:for-each select="xs:Caso">
      <CaseID>
        <xsl:apply-templates select="." />
      </CaseID>
    </xsl:for-each>
  </xsl:template>
</xsl:transform>

It results in:

<?xml version="1.0" encoding="UTF-8"?>
<GetAppointment xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:p="http://ws.wso2.org/dataservice"/>

I guess it is a problem caused by the namespaces. Please help.

Answers


In your xsl: xmlns:xs="http://www.w3.org/2001/XMLSchema"

In your source xml: xmlns:xs="http://ws.wso2.org/dataservice"

Fix this discrepancy, and it should work better.


Need Your Help

iPhone getting compile error ABC Functions forbid explocit messages send of dealoc

ios

When I try to build my project, I get the following error message

TSQL- Rearrange sql job step order in code

sql sql-server-2008 tsql sql-server-2008-r2 database-administration

I have a few SQL maintenance jobs that have upwards of 50 job steps. Occasionally, there is a need to add a step or two to one of these monstrous SQL jobs. The issue I have is that I prefer each st...