2009-10-28 2 views
5

Я пытаюсь удалить атрибут xmlns="http://webdev2003.test.com" из следующего xml, используя xsl/xslt, требование задачи XML в SSIS. Что такое правильная методология, учитывая большой размер файла. ~ 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

Не существует ли надлежащего управления пространством имен в 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 пространства имен. Соответственно при ошибке 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".

Смежные вопросы