472,989 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

Prevent xmlns decalaration in XSLT processing

I'm trying to do XML + XSLT -> Another XML. The source XML contains
multiple namespaces and XSLT will handle all possible tags under each
name space.

----source----
<document xmlns="..." xmlns:a="..." xmlns:b="">
....

----XSLT----
....
<xsl:template match="a:sometag">
....
</xsl:template>
<xsl:template match="b:sometag" />
<xsl:template match="defaultNsInSource:sometag" />
....

The problem I met is the generated xml document always contains
namespace declarations for all name spaces in source xml.

I've tried to add exclude-result-prefixes="yes" or
exclude-result-prefixes="a" in XSLT <xsl:stylesheet> tag, the later one
successfully prevent namespace "a" decalaration from generating, while
the others are still there. Even though there aren't tags under these
name spaces in result xml.

So how to prevent all namespace decalarations from generating into the
result xml?

Thanks

Jul 20 '05 #1
4 8074
Tempore 17:50:37, die Thursday 17 February 2005 AD, hinc in foro {comp.text.xml} scripsit cyclops <ji*******@gmail.com>:
I've tried to add exclude-result-prefixes="yes" or
exclude-result-prefixes="a" in XSLT <xsl:stylesheet> tag, the later one
successfully prevent namespace "a" decalaration from generating, while
the others are still there. Even though there aren't tags under these
name spaces in result xml.

So how to prevent all namespace decalarations from generating into the
result xml?


Hi,

The value of the 'exclude-result-prefixes' attribute is a whitespace seperated list of Qnames. SO in order to prevent namespaces 'a' and 'b' to be added to the result tree, use: exclude-result-prefixes="a b"
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Φιλήκοον ειναι μαλλον η Ï*ιλόλαλον" - Κλεόβουλος
Jul 20 '05 #2
"cyclops" <ji*******@gmail.com> writes:
I'm trying to do XML + XSLT -> Another XML. The source XML contains
multiple namespaces and XSLT will handle all possible tags under each
name space.

----source----
<document xmlns="..." xmlns:a="..." xmlns:b="">
...

----XSLT----
...
<xsl:template match="a:sometag">
...
</xsl:template>
<xsl:template match="b:sometag" />
<xsl:template match="defaultNsInSource:sometag" />
...

The problem I met is the generated xml document always contains
namespace declarations for all name spaces in source xml.

I've tried to add exclude-result-prefixes="yes" or
exclude-result-prefixes="a" in XSLT <xsl:stylesheet> tag, the later one
successfully prevent namespace "a" decalaration from generating, while
the others are still there. Even though there aren't tags under these
name spaces in result xml.

So how to prevent all namespace decalarations from generating into the
result xml?

Thanks


exclude-result-prefixes only affects namespaces that are used on literal
result elements in the stylesheet it has no effect on nodes copied from
the source.

The namespace nodes are being copied from your source tree, this will
not happen by default (only text nodes are copied by default) so it is a
template that you have not shown that is copying the nodes.
if you copy an element node then you always get all its namespaces, if
you don't want that, don't copy it, ie don't use xsl:copy or xsl:copy-of
use <xsl:element name="{name()}"> instead as this generates a fresh
element node with only the namespace nodes for its own namespace (if it
has one) and the xml namespace.

David
Jul 20 '05 #3


cyclops wrote:

So how to prevent all namespace decalarations from generating into the
result xml?


List all the prefixes of namespaces you want to exclude e.g.
<xsl:stylesheet
exclude-result-prefixes="a b c"

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
This works fine for me now.
Once there are more and more name spaces, David's solution
(<xsl:element> tag) might be a better one.
Thank you all for quick response

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rosa M Gmez Flores | last post by:
Hallo! I don't understand exactly what is the 'xmlns' attribute, nor why it have problems with the xmlns attribute of the sylesheet, but I need it in my output XML file. Could anybody tell me...
10
by: Saqib Ali | last post by:
Hello All, I am using Norman Walsh's XSLTs to transform some DocBook XML content to HTML. However I noticed that Norman Walsh's DocBook XSLT includes the following tag in the transformed...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
4
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C#...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
1
by: Rajesh | last post by:
I am trying to pass the namespace, which is in my Original Message, to a Java method for further processing. In the original message the xmlns:xenc namespace is present. I make a call to Java...
0
by: R. Ian Lee | last post by:
I've built an XSLT file that transforms data to SpreadsheetML format. The XSLT uses a <xsl:call-template/to build each worksheet. For some reason, when I transform the file, it is inserting...
3
by: Lee | last post by:
Hello guys, I am new to XML and working on a XSLT to transforn yahoo shopping search result to html. my problem is the return XML contain xmlns in root element, here is the sample xml: <?xml...
2
by: Boris | last post by:
I'm making my first steps with XSLT and run into a problem where I didn't find an explanation yet for. Have a look at this very simple XML document (DocBook) ... <?xml version="1.0"...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.