2009-10-28 15 views
5

Estoy tratando de eliminar el atributo xmlns="http://webdev2003.test.com" del siguiente xml usando xsl/xslt, un requisito de la Tarea XML en SSIS. ¿Cuál es una metodología adecuada considerando un tamaño de archivo grande? ~ 40mbRmove xmlns attribute

<?xml version="1.0" encoding="utf-16"?> 
<ArrayOfAccount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">  
<Account> 
    <FirstName xmlns="http://webdev2003.test.com/">John</FirstName> 
    <LastName xmlns="http://webdev2003.test.com/">Smith</LastName> 
</Account> 
</ArrayOfAccount> 
+0

¿No hay un manejo adecuado del espacio de nombres en SSIS? – Tomalak

Respuesta

0

¿Qué hay de

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsl:template match="*"> 
    <xsl:element name="{name()}"> 
     <xsl:apply-templates select="attribute::*"/> 
     <xsl:if test="namespace-uri()!='http://webdev2003.test.com/' and 
       namespace-uri()!=''"> 
     <xsl:attribute name="xmlns"> 
      <xsl:value-of select="namespace-uri()"/> 
     </xsl:attribute> 
     </xsl:if> 
     <xsl:apply-templates/> 
    </xsl:element> 
    </xsl:template> 

    <xsl:template match="@*"> 
    <xsl:attribute name="{name()}"> 
     <xsl:value-of select="."/> 
    </xsl:attribute> 
    </xsl:template> 
</xsl:stylesheet> 

?

+0

Aparece un error del Bloc de notas XML: no se puede crear un atributo con un nombre local 'xmlns' y un URI de espacio de nombre nulo. Respectivamente en el error MSVS: no se puede crear un atributo con un nombre local 'xmlns' y un URI de espacio de nombre nulo. – decompiled

1

Creo que puede eliminar las declaraciones del espacio de nombres como se describe en this article. Parece que debe declarar un prefijo para el espacio de nombres en su hoja de estilo antes de agregarlo al atributo exclude-result-prefixes.

You can prevent this from happening with the xsl:stylesheet element's exclude-result-prefixes attribute. This attribute's name can be confusing, because the namespace prefixes will still show up in the result tree. It doesn't mean "exclude the prefixes in the result"; it means "exclude the namespaces with these prefixes".