all groups > dotnet xml > february 2004 >
You're in the

dotnet xml

group:

XSLT not closing XHTML tags question


XSLT not closing XHTML tags question Grant Harmeyer
2/5/2004 4:57:57 PM
dotnet xml: I have an XSL file that is being applied to an RSS feed, and it works great
except for 2 things:

1.) XSL doesn't close the <img> tag for xhtml even though I have it being
closed in the XSL file (I've tried <img /> and <img></img>). This blows my
xhtml compatibility.
2.) Also, the RSS feed has a namespace "dc", how do I extract data from the
elements have a dc namespace? I've tried:
<div class="bodysm"><i><xsl:value-of select="dc:creator" /></i></div> <!--
Didn't work -->

Do I need to specify the namespace for xhtml somewhere?

I'm new to XSLT, so I apologize for elementary questions.

<XslFile />
---------------------------------------------------
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" />

<xsl:template match="/rss/channel">

<a href="{image/link}" target="_blank"><img alt="{image/title}"
src="{image/url}"
style="border:0px;height:{image/height}px;width:{image/width}px;" /></a>

<div>
<div><i><a class="rssfeeders" href="{link}"><xsl:value-of
select="description" /></a></i></div>
<div><i><xsl:value-of select="lastBuildDate" /></i></div>
</div>

<p />

<xsl:for-each select="item">
<div><a href="{link}" target="_blank"><b><xsl:value-of select="title"
/></b></a></div>
<div><i><xsl:value-of select="dc:creator" /></i></div><!-- LINE OF
INTEREST -->
<div><i><xsl:value-of select="pubDate" /></i></div><p />
</xsl:for-each>

<p />

</div>

</xsl:template>

</xsl:stylesheet>

Re: XSLT not closing XHTML tags question Steven Livingstone
2/6/2004 7:08:16 AM
It will be because you are setting the method attrib on the output element
to "html". Use the following at instead to get your output Xml campliant.

<xsl:output method="xml" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />

This gives

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Steven
Founder, http://venturetogether.com

[quoted text, click to view]

Re: XSLT not closing XHTML tags question Grant Harmeyer
2/6/2004 12:32:03 PM
Ok, that worked fine and according to validator.w3.org I'm still valid
transitional thank you very much. But what about my second question?
The RSS feed I am reading from has an element <dc:creator /> that is a child
of an <item /> node. How do I use XSL to display this data using simple

<xsl:value-of select="dc:creator" /> type of syntax?

[quoted text, click to view]

Re: XSLT not closing XHTML tags question Steven Livingstone
2/6/2004 5:44:19 PM
Aplogies - i never read that far :)

Anyway - yeah that is the right syntax. Just make sure you have the Dublin
Core namespace declared in the root of the Xslt document - i.e. when you
have defined the xsl prefix.

I am guessing you haven't thus far and so it will throw an exception.

Steven
Founder, http://venturetogether.com

[quoted text, click to view]

AddThis Social Bookmark Button