2014-01-03 4 views
-1

У меня возникли некоторые проблемы, пытаясь превратить этот XML:Преобразование XSL с пространствами имен

<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> 

к этому:

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

Но, используя инструмент, который генерирует этот 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> 

В результате:

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

Я думаю, это проблема, вызванная пространствами имен. Пожалуйста помоги.

ответ

2

В вашем XSL: xmlns:xs="http://www.w3.org/2001/XMLSchema"

В исходном XML: xmlns:xs="http://ws.wso2.org/dataservice"

Fix это несоответствие, и он должен работать лучше.

Смежные вопросы