Jump to content

eulervicente

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About eulervicente

  • Rank
    Newbie
  1. Hi guys! I'm having a problem that it's driving me crazy. It must be simple for most of you, but for me it has been a nightmare. Basically, I need to clean up the namespaces in a XML file for a more friendly reading. I am learning to use XSLT for that, but I am not understanding how to apply the correct XPATH sentence in the XSLT. The original XML file looks like that: <?xml version="1.0" encoding="utf-16"?><cResultado xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Servicos xmlns="http://tempuri.org/"> <cServico> <Codigo>40010</Codigo> <PrazoEntrega>1</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro /> <obsFim /> </cServico> <cServico> <Codigo>50020</Codigo> <PrazoEntrega>3</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro>TESTE</MsgErro> <obsFim /> </cServico> </Servicos></cResultado> I would like to transform it on that: <?xml version="1.0" encoding="utf-16"?><cResultado> <Servicos> <cServico> <Codigo>40010</Codigo> <PrazoEntrega>1</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro /> <obsFim /> </cServico> <cServico> <Codigo>50020</Codigo> <PrazoEntrega>3</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro>TESTE</MsgErro> <obsFim /> </cServico> </Servicos></cResultado> I am using this XSLT to produce the desired XML file, but It doesn't work: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" ><xsl:output method="xml" indent="yes"/><xsl:template match="/"> <Servicos> <xsl:for-each select="//*[local-name() = 'cServico']"> <cServico> <Codigo><xsl:value-of select="Codigo"/></Codigo> <PrazoEntrega><xsl:value-of select="PrazoEntrega"/></PrazoEntrega> <EntregaDomiciliar><xsl:value-of select="EntregaDomiciliar"/></EntregaDomiciliar> <EntregaSabado><xsl:value-of select="EntregaSabado"/></EntregaSabado> <Erro><xsl:value-of select="Erro"/></Erro> <MsgErro><xsl:value-of select="MsgErro"/></MsgErro> <obsFim><xsl:value-of select="obsFim"/></obsFim> </cServico> </xsl:for-each> </Servicos> </xsl:template></xsl:stylesheet> Probably I am not using the correct XPATH sentence in the XSLT because of the namespaces. Could you help with that? Thanks, Euler Almeida
×
×
  • Create New...