xsl-list
[Top] [All Lists]

Re: [xsl] how to remove xmls=""

2019-09-04 02:34:25
one thing i try that adding a default namespace in xsl:stylesheet and got
this error resolved. Please try once like:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema/xs";
   * xpath-default-namespace="http://www.w3.org/2001/XMLSchema/xs
<http://www.w3.org/2001/XMLSchema/xs>"*
    exclude-result-prefixes="xs"
    version="2.0">


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



</xsl:stylesheet>
_________________
Regards,
Amrendra Kr. Gupta
8588817220


On Wed, Sep 4, 2019 at 11:51 AM Dr. Patrik Stellmann
patrik(_dot_)stellmann(_at_)gdv-dl(_dot_)de 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi,



It seems like you misinterpret xmlns to be an ordinary attribute. Instead
it is a namespace declaration for the element.



With your first template you create a new article element **with**
namespace. When the other elements of the input document are copied with
your second template no namespace is being added.

So the question is what you want:

1.      Have all elements in that namespace -> add it in the second
template as well

2.      Don’t use namespace at all -> remove xmlns from first template



Regards,

Patrik



Dr. Patrik Stellmann

Anwendungsarchitektur und Koordination
*GDV Dienstleistungs-GmbH* | Niederlassung Frankenstraße
Tel: +49(40)33449-1142
Fax: +49(40)33449-1400
E-Mail: Patrik(_dot_)Stellmann(_at_)gdv-dl(_dot_)de



*GDV Dienstleistungs-GmbH*
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Niederlassungen:

Wilhelmstraße 43 / 43 G
10117 Berlin

Frankenstraße 18
20097 Hamburg

Sitz und Registergericht: Hamburg
HRB 145291
USt.-IdNr : DE 205183123

Geschäftsführer:
Dr. Jens Bartenwerfer
Fred di Giuseppe Chiachiarella

Aufsichtsratsvorsitzender: Werner Schmidt

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich
geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder
diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die
unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or
privileged information. If you are not the intended recipient (or have
received this e-mail in error) please notify the sender immediately and
destroy this e-mail. Any unauthorised copying, disclosure or distribution
of the material in this e-mail is strictly forbidden.

*Von:* Joga Singh Rawat jrawat(_at_)aptaracorp(_dot_)com [mailto:
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com]
*Gesendet:* Mittwoch, 4. September 2019 08:04
*An:* xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
*Betreff:* [xsl] how to remove xmls=""



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/2718916> (by
email)
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3279967> (by
email <>)

--~----------------------------------------------------------------
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>