XSLT вводит нежелательное пространство имен в выходной файл

Я видел подобные вопросы, но мне все еще неясно. Я не хочу, чтобы пространство имен «n1» отображалось в атрибуте узла в выходном файле. Но мне пришлось создать пространство имен «n1» в файле xslt, чтобы заставить работать xpath. Спасибо.

XSLT:

   <xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:n1="http://www.spicefactory.org/parsley"
        xmlns="http://www.spicefactory.org/parsley"
        >

    <xsl:output method="xml" indent="no"/>

    <xsl:template match="node()|@*">
         <xsl:copy>
           <xsl:apply-templates select="node()|@*"/>
         </xsl:copy>
     </xsl:template>

     <xsl:template match="n1:object[@type='mytype1']">
      <object  type="mytype2">
        <xsl:apply-templates select="node()"/>
      </object>
     </xsl:template>

ВЫДЕРЖКА ИЗ ВЫХОДНОГО XML-ФАЙЛА:

<object type="mytype2" xmlns:n1="http://www.spicefactory.org/parsley">

person dt1000    schedule 11.02.2011    source источник


Ответы (1)


Используйте атрибут exclude-result-prefixes для элемента <xsl:stylesheet>.

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:n1="http://www.spicefactory.org/parsley"
    xmlns="http://www.spicefactory.org/parsley"
    exclude-result-prefixes="n1"
    >
person jasso    schedule 11.02.2011