开发者

XSLT injects unwanted namespace in output file

I've seen similar questions, but it is still unclear to me. I don't want the "n1" namespace to appea开发者_如何学JAVAr in the attribute of the node in the output file. But I had to create the "n1" namespace in the xslt file in order to get xpath to work. Thank you.

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>

EXCERPT FROM OUTPUT XML FILE:

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


Use exclude-result-prefixes attribute on <xsl:stylesheet> element.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜