8

I've seen similar questions, but it is still unclear to me. I don't want the "n1" namespace to appear 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">

1 Answer 1

18

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"
    >
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.