all groups > dotnet xml > august 2005 >
You're in the

dotnet xml

group:

HTML Output in XSLT


HTML Output in XSLT Fredy Muñoz [MCP]
8/22/2005 10:29:01 AM
dotnet xml:
Hello there!

I have a couple of questions about generating HTML using an XSLT Stylesheet.

I use the System.Xml and System.Xml.Xsl namespaces and a XslTransform object
to make the transformation, as follows:

xsltTemplate.Transform(xmlOutput.CreateNavigator, Nothing,
xmlWriter, Nothing)


The XSLT template I use is this one:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="html">
<span>Welcome to the NEXT LEVEL!</span><br/>

<xsl:copy-of select="select"/><br/>
<xsl:copy-of select="div/a"/><br/>

<span>Welcome to the NEXT LEVEL!</span>
<a href="Home.aspx?id=a&id2=b" at="at">a</a>
<br/>
<!--<xsl:text> </xsl:text>-->
</xsl:template>
</xsl:stylesheet>

I need that the HTML Output includes the HTML entity but instead it
outputs a &nbsp; string. Also I want to write the href attribute of the <a>
elements on the xstl stylesheet without the need of the & XML entity in as
parameter separator like this: page.aspx?a=1&b=2 instead of this:
page.aspx?a=1&amp;b=2

I've already tried adding the <xsl:output> element with the HTML method, but
I get the same resutls.

Re: HTML Output in XSLT Fredy Muñoz [MCP]
8/22/2005 11:00:04 AM
Re: HTML Output in XSLT Martin Honnen
8/22/2005 7:47:29 PM


[quoted text, click to view]

Well
<a href="page.aspx?a=1&amp;b=2">
is correct HTML while
<a href="page.aspx?a=1&b=2">
is not, try an HTML validator.
So the result is fine if you want HTML output.


--

Martin Honnen --- MVP XML
Re: HTML Output in XSLT Oleg Tkachenko [MVP]
8/23/2005 10:42:43 AM
[quoted text, click to view]

Beware that when transforing to XmlWriter you are generating XML, not
HTML (xsl:output instruction is ignored). Transform to Stream or
TextWriter to get real HTML.
ANd there is no way to get entities out of XSLT, it just has no idea
what they are. You can postprocess transformation result to convert
charcters to entities, but usually that makes no sense.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
AddThis Social Bookmark Button