2009-10-28 3 views
5

SSIS의 XML 작업 요구 사항 인 xsl/xslt를 사용하여 다음 xml에서 xmlns="http://webdev2003.test.com" 특성을 제거하려고합니다. 큰 파일 크기를 고려한 적절한 방법론은 무엇입니까? ~ 40메가바이트Rmove xmlns 특성

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

SSIS에서 적절한 네임 스페이스 처리가 있습니까? – Tomalak

답변

0

무엇

<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

XML Notepad에서 오류가 발생합니다. 로컬 이름이 'xmlns'이고 null 네임 스페이스 URI가있는 속성을 만들 수 없습니다. MSVS 오류에서 각각 : 로컬 이름이 'xmlns'이고 null 네임 스페이스 URI가있는 속성을 만들 수 없습니다. – decompiled

1

this article에서 설명한대로 네임 스페이스 선언을 제거 할 수 있다고 생각합니다. 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".