473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XSLT: I don't get the xmlns in target

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 how to transform this input:

<ROOT-ELEMENT>
<SOHN>...</SOHN>
</ROOT-ELEMENT>

in this output:

<ROOT-ELEMENT xmlns="http://www.whatever">
<SOHN>...</SOHN>
</ROOT-ELEMENT>

Thanks a lot of,

Rgf

Jul 20 '05 #1
7 2005
"Rosa Mª Gómez Flores" <fi*******@auna.com> wrote in message
news:bm************@news1s.iddeo.es

Could anybody tell me how to transform this input:

<ROOT-ELEMENT>
<SOHN>...</SOHN>
</ROOT-ELEMENT>

in this output:

<ROOT-ELEMENT xmlns="http://www.whatever">
<SOHN>...</SOHN>
</ROOT-ELEMENT>


<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/ROOT-ELEMENT">
<xsl:element name="ROOT-ELEMENT" namespace="http://www.whatever">
<xsl:copy-of select="./*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Martin
Jul 20 '05 #2
This is not the correct solution -- the copied nodes will not belong to the
namespace of ROOT-ELEMENT.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Martin Boehm" <ng********@arcor.de> wrote in message
news:3f***********************@newsread2.arcor-online.net...
"Rosa Mª Gómez Flores" <fi*******@auna.com> wrote in message
news:bm************@news1s.iddeo.es

Could anybody tell me how to transform this input:

<ROOT-ELEMENT>
<SOHN>...</SOHN>
</ROOT-ELEMENT>

in this output:

<ROOT-ELEMENT xmlns="http://www.whatever">
<SOHN>...</SOHN>
</ROOT-ELEMENT>


<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/ROOT-ELEMENT">
<xsl:element name="ROOT-ELEMENT" namespace="http://www.whatever">
<xsl:copy-of select="./*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Martin

Jul 20 '05 #3
In article <bm************@news1s.iddeo.es>,
Rosa Mª Gómez Flores <fi*******@auna.com> wrote:
I don't understand exactly what is the 'xmlns' attribute, nor why it have
problems with the xmlns attribute of the sylesheet,


You might want to find out more before blindly pressing ahead, but
this copies a document, placing all elements in the http://www.whatever
namespace:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="http://www.whatever">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>

<xsl:template match="@*|comment()|processing-instruction()|text()">
<xsl:copy/>
</xsl:template>

</xsl:stylesheet>

-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #4
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:bm************@ID-152440.news.uni-berlin.de...
This is not the correct solution -- the copied nodes will not belong to the namespace of ROOT-ELEMENT.


Here's a better one:

<xs:stylesheet xmlns:xs="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xs:output method="xml" omit-xml-declaration="yes"/>
<xs:template match="*" priority="1.0">
<xs:element name="{name(.)}" namespace="http://example.com">
<xs:apply-templates select="@*|node()"/>
</xs:element>
</xs:template>
<xs:template match="@*|node()">
<xs:copy>
<xs:apply-templates select="@*|node()"/>
</xs:copy>
</xs:template>
</xs:stylesheet>

Bob Foster
Jul 20 '05 #5
Here's a better one:


Yes, I already provided exactly the same in microsoft.public.xsl -- as I
pointed to Rosa, no one would reply to her identical messages in 3 forums.
In microsoft.public.xml Marrow posted a slightly better one -- the default
namespace is declared on the xsl:stylesheet element and does not need to be
specified on the xsl:element instructions.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Jul 20 '05 #6
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:bm************@ID-152440.news.uni-berlin.de...
In microsoft.public.xml Marrow posted a slightly better one -- the default
namespace is declared on the xsl:stylesheet element and does not need to be specified on the xsl:element instructions.


I don't know how to do that. What does it look like?

Bob
Jul 20 '05 #7
http://groups.google.com/groups?dq=&...3DN%26tab%3Dwg
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Bob Foster" <bo********@comcast.net> wrote in message
news:0PLib.766276$uu5.133458@sccrnsc04...
"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:bm************@ID-152440.news.uni-berlin.de...
In microsoft.public.xml Marrow posted a slightly better one -- the default namespace is declared on the xsl:stylesheet element and does not need to

be
specified on the xsl:element instructions.


I don't know how to do that. What does it look like?

Bob

Jul 20 '05 #8

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

Similar topics

8
by: Ola Natvig | last post by:
Anybody out there who knows if the 4suite implementation of XSLT are a threadsafe one? -- -------------------------------------- Ola Natvig <ola.natvig@infosense.no> infoSense AS / development
2
by: Geathaa | last post by:
Hi everyone, I want to transform a xml document containing the description of a menu tree to HTML. The MenuTree XML contains the target URL for each tree node. Some URL's contain parameters...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
4
by: mikea_59 | last post by:
I'm getting different results from XMLSpy and Saxon translations - both are updated versions. Maybe someone here can give me some insight. Here is my input: <MESSAGE> <msgName> <B enum="1">...
2
by: FrankStallone | last post by:
I am just getting started in XML and I made my first xml, dtd and xslt file and XML spy said they were all valid and they worked. This was the xslt doc that worked. <?xml version="1.0"...
7
by: One Handed Man \( OHM - Terry Burns \) | last post by:
I've been battling with this stupid problem for hours now. WebApp: Trying to do a simple transformation using XSLT to a Web Page, but it just failes without an error message ( In other words,...
6
by: Neal | last post by:
Hi All, I wrote a TOC treeview using xml and xslt, with help from this forum and MSDN help(thanks) Great in IE 6. (expect IE 5 as well, articles were circa 2000) However, Mozilla FireFox...
8
by: Hercules Dev. | last post by:
Hi all, I'm new in xslt and xpath, so my question might be simple but i'm learning. I have an XML document and need to transform it into another XML, I use xslt and it works, but there is a...
2
by: mdawg | last post by:
I am attempting to use the XSLT document function to extract the value of an attribute in a secondary XML file. In order to add an image to the generatedHTML Both xml files I am dealing with are...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...

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.