473,657 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble transforming document element

I'm trying to transform the document element of incoming xml files, however,
I'm having trouble with namespace references not appearing correctly. Here's
an example input file:

<?xml version="1.0" encoding="utf-8" ?>
<inputdoc xmlns:a="http://www.dummy.org" something="true ">
<hello somethingelse=" false" />
<foo>
<!-- a comment -->
<bar />
</foo>
</inputdoc>

All I want to do at the moment is to transform the document element from
<inputdoc> to <outputdoc> using XSLT. (I do other transformations as well,
but they are irrelevant for this question.) And yes, I do realise that I'm
not actually using the namespace http://www.dummy.org anywhere.

The best output I am able to get is this:

<?xml version="1.0" encoding="UTF-8"?>
<outputdoc something="true ">
<hello xmlns:a="http://www.dummy.org" somethingelse=" false"/>
<foo xmlns:a="http://www.dummy.org">
<!-- a comment -->
<bar/>
</foo>
</outputdoc>

This is semantically ok, but I would like the namespace references to stay
attached to the document element. Here is the transformation I'm using:

<?xml version='1.0' encoding='UTF-8' ?>
<xsl:transfor m version='1.0'
xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'>
<xsl:template match='inputdoc '>
<xsl:element name='outputdoc '>
<xsl:apply-templates
select='*|@*|te xt()|comment()| processing-instruction()' />
</xsl:element>
</xsl:template>
<xsl:template match='*|@*|tex t()|comment()|p rocessing-instruction()'>
<xsl:copy>
<xsl:apply-templates
select='*|@*|te xt()|comment()| processing-instruction()' />
</xsl:copy>
</xsl:template>
</xsl:transform>

I've tried with both Xalan and the .NET Framework's XslTransform. They
produce the same results. How should I adapt the transformation so that the
namespace references are left intact?

--
Tor
Jul 20 '05 #1
0 1580

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

Similar topics

0
1550
by: Michael Birkmose | last post by:
Hi everyone! I am new to XSL and I was wondering if the following is possible: XML ======= <document title="Hello World"> <menu> <menuitem>Test</menuitem>
2
1797
by: Mirjana Rakuljic | last post by:
Hi, I need help with transforming XML document. I generate xml document from query using Oracle XSU (DBMS_XMLQUERY) and the document I get is like this: <?xml version = '1.0' encoding = 'ISO-8859-1'?> <MultiPAT> <PAT> <numreferencia>000000000000</numreferencia>
8
2006
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts to that button, so there is no text to be selected. What should I do? Below you'll see some code that I have in one of my forms. I was hoping to have these buttons and when I click on them they would take selected text from a textarea box and...
1
2695
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff working, but it only worked for IE. You can see a working version here: http://www.publicpen.com/designer/mcControlPanel.php username: designer password: designer123 However, I've tried to rewrite this so it would work in all browsers,
3
1334
by: Mike | last post by:
I'm trying to write a XSL style sheet that will transform a SOAP document into a different type of SOAP document. However, if I try to create an element in my style sheet of "<xsl:element name="SOAP-ENV:Envelope>", nothing gets generated. The problem is with the ":Envelope". If I remove that then it works fine. I believe the ":Envelope" is referred to as an Element Extension but I can't figure out exactly what I need to do to get...
4
2022
by: Cathie | last post by:
Hi All, I am trying to get my style sheet to work. It works fine in IE but I can't get it to work in .net. Below is the function I use for transforming, where advancedOptionsFile is the path to the file containing an XML document required by the transformation, and xmlSimplified is the XML document to trasform. ---------------------------------------------------------------------------- -------------------------------
1
2420
by: MaggotChild | last post by:
Hi, I'm trying to transform the values entered into a form: HTML: <div id="container"> <div id="bs"> <input id="name" type="text"/> <p>PPPPP</p> <a href="#" onclick="return transform()">Do it!</a> </div>
2
2275
by: doozer1979 | last post by:
Hello, I'm having a bit of difficulty transforming xml elements into attributes. I want to loop through all of the <person> elements in the document and turn all of its child elements into attributes of the person element. The code i am using takes the last <person> element and changes all of its elements into attributes of the root node and then removes all of child elements of every person element. This is the code that i am...
5
13348
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.