2009-10-28 6 views
5

Próbuję usunąć atrybut xmlns="http://webdev2003.test.com" z następującego xml przy użyciu xsl/xslt, wymaganie Zadanie XML w SSIS. Jaka jest właściwa metodologia, biorąc pod uwagę duży rozmiar pliku. ~ 40MBRmove xmlns atrybut

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

Czy w SSIS nie ma właściwej obsługi przestrzeni nazw? – Tomalak

Odpowiedz

0

Co

<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

Występuje błąd z Notatnika XML - nie można utworzyć atrybutu o lokalnej nazwie "xmlns" i pustego identyfikatora URI przestrzeni nazw. Odpowiednio w przypadku błędu MSVS: nie można utworzyć atrybutu o lokalnej nazwie "xmlns" i pustego identyfikatora URI przestrzeni nazw. – decompiled

1

Myślę, że możesz usunąć deklaracje przestrzeni nazw zgodnie z opisem w this article. Wygląda na to, że możesz zadeklarować prefiks dla przestrzeni nazw w swoim arkuszu stylów, zanim dodasz go do atrybutu przedrostek-wynik-prefiks.

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

Powiązane problemy