xsl-list
[Top] [All Lists]

[xsl] how to remove xmls=""

2019-09-04 01:03:27
Dear Expert,
I am getting <front xmlns=""> and <body xmlns=""> as output from below 
combination of input xml and xslt. Please let us know how to remove xmlns=””.

INPUT
<article xmlns:mml="http://www.w3.org/1998/Math/MathML"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:oasis="http://www.niso.org/standards/z39-96/ns/oasis-exchange/table"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:ali="http://www.niso.org/schemas/ali/1.0/"; 
article-type="research-article" dtd-version="1.1" xml:lang="en">
<front>
...
</front>
<body>
...</body>
</article>

XSLT
<xsl:template match="article">
    <article 
xmlns="http://specifications.silverchair.com/xsd/1/18/SCJATS-journalpublishing.xsd";>
        <xsl:if test="@article-type">
            <xsl:attribute name="article-type" select="@article-type"/>
        </xsl:if>
        <xsl:if test="@xml:lang">
            <xsl:attribute name="xml:lang" select="@xml:lang"/>
        </xsl:if>
        <xsl:attribute 
name="xsi:schemaLocation">http://specifications.silverchair.com/xsd/1/19/SCJATS-journalpublishing.xsd
 
http://specifications.silverchair.com/xsd/1/19/SCJATS-journalpublishing.xsd</xsl:attribute>
        <xsl:apply-templates/>
    </article>
</xsl:template>

<xsl:template match="node() | @*">
    <xsl:copy copy-namespaces="no" inherit-namespaces="no">
        <xsl:apply-templates select="node() | @*[not(name()='xmlns')]"/>
    </xsl:copy>
</xsl:template>

OUTPUT
<article 
xmlns="http://specifications.silverchair.com/xsd/1/18/SCJATS-journalpublishing.xsd";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xmlns:mml="http://www.w3.org/1998/Math/MathML";
         article-type="research-article"
         xml:lang="en"
         
xsi:schemaLocation="http://specifications.silverchair.com/xsd/1/19/SCJATS-journalpublishing.xsd
 http://specifications.silverchair.com/xsd/1/19/SCJATS-journalpublishing.xsd";>
   <front xmlns="">
    ...
   </front>
   <body xmlns="">
   ...
</body>
</article>

thanks in advance
...JSR
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>