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
Pascal Schmitt - 05 Aug 2005 12:17 GMT
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>

Signature
Pascal Schmitt
Deepak - 05 Aug 2005 13:45 GMT
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.
----------------------------------------------------------------------
> Hi
> What I need to do is to take the following XML (or some variant of it):
[quoted text clipped - 45 lines]
>
> Marek
Mekett - 18 Aug 2005 10:46 GMT
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