473,387 Members | 1,619 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,387 software developers and data experts.

HTML tags within XML element rendered to HTML document

Hi
What I need to do is to take the following XML (or some variant of it):
<?xml version="1.0" encoding="UTF-8"?>
<MyRawHTML>
<H1>Hello, world!</H1>
</MyRawHTML>

And apply an XSLT to it along the lines of:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<p>
<xsl:value-of select="/MyRawHTML" />

<!-- This doesn't work either:
<![CDATA[<H1>Hello, world!</H1>]]>
-->

</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

So that I get:

<html>
<head>
</head>
<body>
<p>
<H1>Hello, world!</H1>
</p>
</body>
</html>
Is this possible? I have tried to use CDATA, but I just get the text
"<H1>Hello, world!</H1>" coming through instead.

Thank you for any help anyone can provide.

Marek
Nov 12 '05 #1
3 2271
Hello!
What I need to do is to take the following XML (or some variant of it):
<?xml version="1.0" encoding="UTF-8"?>
<MyRawHTML>
<H1>Hello, world!</H1>
</MyRawHTML>


Value-Of is wrong here, it converts everything to a string (if you put
it here).

Use copy-of:
<xsl:copy-of select="/MyRawHTML/*/node()" />

This copies all the content of MyRawHTML, including Attributes to the
output.

Beware of namespace problems!

<MyRawHTML xmlns="urn:foo">
<h1>Hello, world!</h1>
</MyRawHTML>

Will give you this:

<html xmlns="http://www.w3.org/1999/xhtml/">
<body>
<h1 xmlns="urn:foo">Hello, world!</h1>
</body>
</html>

This means, that the h1-Element is not an HTML-Element and will not be
rendered as you thought by some browsers (Mozilla).

This will give you the output you wish:

<MyRawHTML xmlns="urn:foo">
<h1 xmlns="http://www.w3.org/1999/xhtml/>Hello, world!</h1>
</MyRawHTML>
--
Pascal Schmitt
Nov 12 '05 #2
It will work if your XML is as follows instead of ur XSLT

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xslt"?>
<MyRawHTML>
<![CDATA[<H1>Hello, world!</H1>]]>
</MyRawHTML>

Can you get your XML in this format?
If not - then we can look @ some other Solution.
----------------------------------------------------------------------

"Marek" wrote:
Hi
What I need to do is to take the following XML (or some variant of it):
<?xml version="1.0" encoding="UTF-8"?>
<MyRawHTML>
<H1>Hello, world!</H1>
</MyRawHTML>

And apply an XSLT to it along the lines of:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<p>
<xsl:value-of select="/MyRawHTML" />

<!-- This doesn't work either:
<![CDATA[<H1>Hello, world!</H1>]]>
-->

</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

So that I get:

<html>
<head>
</head>
<body>
<p>
<H1>Hello, world!</H1>
</p>
</body>
</html>
Is this possible? I have tried to use CDATA, but I just get the text
"<H1>Hello, world!</H1>" coming through instead.

Thank you for any help anyone can provide.

Marek

Nov 12 '05 #3

I have te same problem as Marek:
I want to use HTML tags in the XML data file, and I want to keep these
tags in the output.

I tried the CDATA all way, and it doesn't work.
This thing with the "node()" doesn't work too.

But it seems good. Maybe some mistake in the example? (not the double
quote)

Plz help me!
Thanks

--
Mekett
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1774249.html

Nov 12 '05 #4

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

Similar topics

7
by: Ed Lai | last post by:
A few weeks ago I have the idea of converting XML instance data to a HTML form, using tags as the label and the resulting form can be used to edit the XML data. So I started to play around with it,...
5
by: Donald Firesmith | last post by:
Are html tags allowed within meta tags? Specifically, if I have html tags within a <definition> tag within XML, can I use the definition as the content within the <meta content="description> tag? ...
10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
54
by: Howard Kaikow | last post by:
Where is the official documentation of what constitutes a minimally compliant HTML file? -- http://www.standards.com/; See Howard Kaikow's web site.
19
by: Eric Lindsay | last post by:
Should HTML 4.01 Strict markup be done in upper case or in lower case? I understand that HTML allows either upper or lower case. I also notice that XHTML apparently requires lower case. However I...
82
by: Eric Lindsay | last post by:
I have been trying to get a better understanding of simple HTML, but I am finding conflicting information is very common. Not only that, even in what seemed elementary and without any possibility...
4
by: Arthur Dent | last post by:
Hello all, ive been programming with ASP.NET since it came out, but am just getting my feet with now with v.2. Ive noticed something strange in the way my HTML tables get rendered with 2. I use...
4
by: sysxperts | last post by:
Hi, I have a mail server that generates archives in a directory for every message sent or received and each archive has an associated XML file with <sender>, <receiver>, <subject> and other...
12
by: Peter Michaux | last post by:
Hi, I am experimenting with some of the Ruby on Rails JavaScript generators and see something I haven't before. Maybe it is worthwhile? In the page below the script is enclosed in //<!]> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.