Discussion:
Remove Namespace from ouput's root element
Ramkumar.V
2010-10-26 07:16:42 UTC
Permalink
Hi, List

I doing xml to xml transformation using xslt2.0 with Saxon.

My Input XML uses namespace at the root element is: xmlns:xlink="http://www.w3.org/1999/xlink" and some elements used this attributes like xlink:href="something".

The same namespace is coming to my transformed output xml at the root element. But this namespace is not used by any element in output xml.

I like to remove or avoid this namespace also i am getting xml parsing error due to this.

Could you please any one suggest me for the above issue?

Regards,

Ram Kumar V.



===========================================================
***Disclaimer***


This email, and any attachments ("this email"), is confidential. If you are not the addressee please tell the sender immediately, and destroy this email without using, sending or storing it. Any opinions, express or implied, in this email, are those of the sender, and are not necessarily approved by the company. Except as expressly stated, this e-mail should not be regarded as an offer, solicitation, recommendation or agreement to buy or sell products or services, or to enter into any contract. E-mail transmissions are not secure and may suffer errors, viruses, delay, interception and amendment. The company does not accept liability for damage caused by any of the foregoing.

ALL INCOMING AND OUTGOING MAILS MAY BE MONITORED BY THE COMPANY.
============================================================

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Martin Honnen
2010-10-26 13:55:32 UTC
Permalink
Post by Ramkumar.V
I doing xml to xml transformation using xslt2.0 with Saxon.
xmlns:xlink="http://www.w3.org/1999/xlink" and some elements used this
attributes like xlink:href="something".
The same namespace is coming to my transformed output xml at the root
element. But this namespace is not used by any element in output xml.
I like to remove or avoid this namespace also i am getting xml parsing error due to this.
Could you please any one suggest me for the above issue?
Well we need to see the relevant templates to suggest the proper
changes. I assume you use xsl:copy or xsl:copy-of and that by default
copies any namespace nodes. If you don't want that then with XSLT 2.0
you can use copy-namespace and inherit-namespaces to change that behaviour.

As for the parse error, please post more details on that.
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Michael Kay
2010-10-26 13:57:36 UTC
Permalink
Probably you are using <xsl:copy> to copy the root element of the input
document to create the root element of the output document. If that is
the case, try <xsl:copy copy-namespaces="no">. If that doesn't work,
please post a cut-down working example.

Michael Kay
Saxonica
Post by Ramkumar.V
Hi, List
I doing xml to xml transformation using xslt2.0 with Saxon.
xmlns:xlink="http://www.w3.org/1999/xlink" and some elements used this
attributes like xlink:href="something".
The same namespace is coming to my transformed output xml at the root
element. But this namespace is not used by any element in output xml.
I like to remove or avoid this namespace also i am getting xml parsing error due to this.
Could you please any one suggest me for the above issue?
Regards,
Ram Kumar V.
===========================================================
***Disclaimer***
This email, and any attachments ("this email"), is confidential. If
you are not the addressee please tell the sender immediately, and
destroy this email without using, sending or storing it. Any opinions,
express or implied, in this email, are those of the sender, and are
not necessarily approved by the company. Except as expressly stated,
this e-mail should not be regarded as an offer, solicitation,
recommendation or agreement to buy or sell products or services, or to
enter into any contract. E-mail transmissions are not secure and may
suffer errors, viruses, delay, interception and amendment. The company
does not accept liability for damage caused by any of the foregoing.
ALL INCOMING AND OUTGOING MAILS MAY BE MONITORED BY THE COMPANY.
============================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
p***@thomsondigital.com
2010-10-27 04:30:03 UTC
Permalink
Until an unless you won't tell your exact requirement it will be difficult
to suggest anything:

What Martin and Michael has suggested works perfectly for me in 2.0. Even
the below one works for me in 1.0:

<xsl:template match="root">
<xsl:element name="root">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

Are you trying to remove any specific namespace or all of them in root
element? Please post the sample input and required output.

HTH,
Pankaj Chaturvedi


--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
p***@thomsondigital.com
2010-10-27 07:51:29 UTC
Permalink
Until an unless you won't tell your exact requirement it will be difficult
to suggest anything:

What Martin and Michael has suggested works perfectly for me in 2.0. Even
the below one works for me in 1.0:

<xsl:template match="root">
<xsl:element name="root">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

Are you trying to remove any specific namespace or all of them in root
element? Please post the sample input and required output.

HTH,
Pankaj Chaturvedi


--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Ramkumar.V
2010-10-28 05:49:37 UTC
Permalink
Hi, Pankaj

I am not using the below code 'xsl:copy' to match the root element.
Please find the below my input XML and XSLT for my issues.

I didn't get solved this issue. I need to remove the namespace from the
output xml, this namespace not used in output xml.

Input XML
========
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article">
<front>
<journal-meta><journal-id
journal-id-type="publisher-id">JPP</journal-id></journal-meta>
<article-meta>
<article-id
pub-id-type="doi">10.1177/1059840510312345</article-id>
<volume>XX23</volume>
<issue>X2</issue>
<abstract><p>Abstract Text</p></abstract>
</article-meta>
</front>
<ref>
<citation citation-type="web"><ext-link ext-link-type="uri"
xlink:href="http://www.nydailynews.com/lifestyle/health/2009/02/03/2009-02-03_red_bull_energy_drink_eyed_in_death_of_b.html">http://www.nydailynews.com/lifestyle/health/2009/02/03/2009-02-03_red_bull_energy_drink_eyed_in_death_of_b.html</ext-link>
</citation></ref>
</article>

XSLT
=====
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:output method="xml" encoding="us-ascii" indent="no"
omit-xml-declaration="no" include-content-type="no" />
<xsl:template match="article">
<hml
artid="{descendant::journal-id[@journal-id-type='publisher-id']}_{substring(substring-after(descendant::article-id[@pub-id-type='doi'],'/'),11,6)}"
jnlid="HML" publisher="Hurix" vol="{descendant::volume[1]}"
issue="{descendant::issue[1]}" month="{descendant::month[1]}"
pubyear="{descendant::year[1]}" doctype="{@article-type}"
doi="{descendant::article-id[@pub-id-type='doi']}">
<xsl:apply-templates/>
</hml>
</xsl:template>
<xsl:template match="citation[@citation-type='web']">
<ref-url>
<url id="url"
href="{descendant-or-self::ext-link/@xlink:href}"><xsl:apply-templates
select="ext-link"/></url>
</ref-url>
</xsl:template>
<xsl:template match="front"/>
</xsl:stylesheet>

Current Output
==========
<?xml version="1.0" encoding="us-ascii"?><hml
xmlns:xlink="http://www.w3.org/1999/xlink" artid="JPP_312345"
jnlid="HML" publisher="Hurix" vol="XX23" issue="X2" month="" pubyear=""
doctype="research-article" doi="10.1177/1059840510312345">
<ref-url><url id="url"
href="http://www.nydailynews.com/lifestyle/health/2009/02/03/2009-02-03_red_bull_energy_drink_eyed_in_death_of_b.html">http://www.nydailynews.com/lifestyle/health/2009/02/03/2009-02-03_red_bull_energy_drink_eyed_in_death_of_b.html</url></ref-url>

</hml>

Expected Output
============
<?xml version="1.0" encoding="us-ascii"?><hml artid="JPP_312345"
jnlid="HML" publisher="Hurix" vol="XX23" issue="X2" month="" pubyear=""
doctype="research-article" doi="10.1177/1059840510312345">
<ref-url><url id="url"
href="http://www.nydailynews.com/lifestyle/health/2009/02/03/2009-02-03_red_bull_energy_drink_eyed_in_death_of_b.html">http://www.nydailynews.com/lifestyle/health/2009/02/03/2009-02-03_red_bull_energy_drink_eyed_in_death_of_b.html</url></ref-url>

</hml>

Regards,
Ramkumar



===========================================================
***Disclaimer***


This email, and any attachments ("this email"), is confidential. If you are not the addressee please tell the sender immediately, and destroy this email without using, sending or storing it. Any opinions, express or implied, in this email, are those of the sender, and are not necessarily approved by the company. Except as expressly stated, this e-mail should not be regarded as an offer, solicitation, recommendation or agreement to buy or sell products or services, or to enter into any contract. E-mail transmissions are not secure and may suffer errors, viruses, delay, interception and amendment. The company does not accept liability for damage caused by any of the foregoing.

ALL INCOMING AND OUTGOING MAILS MAY BE MONITORED BY THE COMPANY.
============================================================

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Ganesh Babu N
2010-10-28 06:04:21 UTC
Permalink
Dear Ramkumar,

Include exclude-result-prefixes="xlink" to your stylesheet element.

Regards,
Ganesh
Post by p***@thomsondigital.com
Until an unless you won't tell your exact requirement it will be difficult
What Martin and Michael has suggested works perfectly for me in 2.0. Even
<xsl:template match="root">
<xsl:element name="root">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
Are you trying to remove any specific namespace or all of them in root
element? Please post the sample input and required output.
HTH,
Pankaj Chaturvedi
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Ramkumar.V
2010-10-28 13:44:02 UTC
Permalink
Dear Ganesh

It's working. Thanks.

Regards,
Ramkumar
Post by Ganesh Babu N
Dear Ramkumar,
Include exclude-result-prefixes="xlink" to your stylesheet element.
Regards,
Ganesh
===========================================================
***Disclaimer***


This email, and any attachments ("this email"), is confidential. If you are not the addressee please tell the sender immediately, and destroy this email without using, sending or storing it. Any opinions, express or implied, in this email, are those of the sender, and are not necessarily approved by the company. Except as expressly stated, this e-mail should not be regarded as an offer, solicitation, recommendation or agreement to buy or sell products or services, or to enter into any contract. E-mail transmissions are not secure and may suffer errors, viruses, delay, interception and amendment. The company does not accept liability for damage caused by any of the foregoing.

ALL INCOMING AND OUTGOING MAILS MAY BE MONITORED BY THE COMPANY.
============================================================

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Neil Owens
2010-10-28 18:51:02 UTC
Permalink
I just can't figure out the syntax here

I'm passing a directory location into Saxon as a parameter.  Only I need to make every '\' character in the (windows) directory path a '\\' for the uri in the transform.  As it's only the transform that needs this I thought I'd do the conversion in the transform.  And it's beaten me.

The command line param is: ...path="C:\Documents and Settings\Adminis
trator\My Documents\Projects\Transform\OutputFiles"

I've got this neatly passed into the transform with:

<xsl:param name="path"></xsl:param>
...
<xsl:template match="Log">
        <xsl:value-of select= replace($path, '\\', '\\')" />
        <xsl:variable name="Command" select="concat($path, '\\OutputFiles\\Command-output.xml')" />
        <xsl:result-document method="xml" href="{$Command}">
        .....


But fails and I just can't figure out how to achieve setting the result-document href to equal "C:\\Documents and Settings\\Administrator\\My Documents\\Projects\\Transform\OutputFiles"

I know I can (I tried and it works) just add the correct number of backslashes to the command line param, but I don't want to.

As ever, thanks in advance...

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
David Carlisle
2010-10-28 19:03:18 UTC
Permalink
Post by Neil Owens
I just can't figure out the syntax here
I'm passing a directory location into Saxon as a parameter. Only I need to make every '\' character in the (windows) directory path a '\\' for the uri in the transform. As it's only the transform that needs this I thought I'd do the conversion in the transform. And it's beaten me.
why? UROs never use \ to separate components they always use / and \
isn't an escape character in xpath strings so you never need to double \/
Post by Neil Owens
The command line param is: ...path="C:\Documents and Settings\Adminis
trator\My Documents\Projects\Transform\OutputFiles"
<xsl:param name="path"></xsl:param>
...
<xsl:template match="Log">
<xsl:value-of select= replace($path, '\\', '\\')" />
<xsl:variable name="Command" select="concat($path, '\\OutputFiles\\Command-output.xml')" />
<xsl:result-document method="xml" href="{$Command}">
.....
But fails and I just can't figure out how to achieve setting the result-document
href to equal "C:\\Documents and Settings\\Administrator\\My
Documents\\Projects\\Transform\OutputFiles"

you want a URI not a windows file path with doubled \

file:///c:/Documents%20and%20Settings\\Administrator\\My%20Documents\\Projects\\Transform\OutputFiles

David
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--
Michael Kay
2010-10-28 22:30:11 UTC
Permalink
Post by Neil Owens
I just can't figure out the syntax here
I'm passing a directory location into Saxon as a parameter. Only I need to make every '\' character in the (windows) directory path a '\\' for the uri in the transform. As it's only the transform that needs this I thought I'd do the conversion in the transform. And it's beaten me.
The href attribute of xsl:result-document expects a URI, not a Windows
filename, and URIs always use forward slashes to separate components of
the path.

Even if it were a backslash, the backslash is not a special character in
XPath and does not need escaping.

Moreover: string concatenation is an unreliable way of constructing a
URI from a base URI plus a relative reference. Much better to use the
resolve-uri() function. (I'm afraid this is advice I don't always follow
myself, but I often end up regretting it.)

Michael Kay
Saxonica
Post by Neil Owens
The command line param is: ...path="C:\Documents and Settings\Adminis
trator\My Documents\Projects\Transform\OutputFiles"
<xsl:param name="path"></xsl:param>
...
<xsl:template match="Log">
<xsl:value-of select= replace($path, '\\', '\\')" />
<xsl:variable name="Command" select="concat($path, '\\OutputFiles\\Command-output.xml')" />
<xsl:result-document method="xml" href="{$Command}">
.....
But fails and I just can't figure out how to achieve setting the result-document href to equal "C:\\Documents and Settings\\Administrator\\My Documents\\Projects\\Transform\OutputFiles"
I know I can (I tried and it works) just add the correct number of backslashes to the command line param, but I don't want to.
As ever, thanks in advance...
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-***@lists.mulberrytech.com>
--~--

Loading...