2009-10-28 2 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

答えて

3

私は自分の質問に答えるとき、私は嫌いますが、クレジットがに行く - http://blogs.msdn.com/kaevans/archive/2003/06/13/8679.aspx

例の最初の部分は私のシナリオで動作するすべての属性を削除する方法を示しています。おそらくもっと良い解決策がありますか?

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'で、名前空間URIがnullの属性を作成できません。 MSVSエラーでそれぞれ:ローカル名「xmlns」およびヌル名前空間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".

関連する問題