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

XSLT not closing XHTML tags question

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>
Nov 12 '05 #1
3 2705
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

"Grant Harmeyer" <gn*********@hotmail.com> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
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>

Nov 12 '05 #2
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?

"Steven Livingstone" <s.***********@nospam.btinternet.com> wrote in message
news:eq**************@TK2MSFTNGP11.phx.gbl...
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

"Grant Harmeyer" <gn*********@hotmail.com> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
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>


Nov 12 '05 #3
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

"Grant Harmeyer" <gn*********@hotmail.com> wrote in message
news:#M**************@TK2MSFTNGP12.phx.gbl...
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?

"Steven Livingstone" <s.***********@nospam.btinternet.com> wrote in message news:eq**************@TK2MSFTNGP11.phx.gbl...
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

"Grant Harmeyer" <gn*********@hotmail.com> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
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>



Nov 12 '05 #4

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

Similar topics

3
by: Francis Hwang | last post by:
Hi, Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags? I can imagine that...
2
by: full_philNO | last post by:
Hi all, I have a problem with the img tag. It simply doesn't want to translate into a img XHTML tag. When I write in XSLT : <img src="..." alt="..." ..../> or <img src=".." alt="..."...
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
6
by: Mike P | last post by:
I am quite new to XML and XSLT, and I know you can apply XSLT to XML to display data in an XML file according to the XSLT file, but is it possible to apply an XSLT file to page/s of HTML, so that...
4
by: dwergkees | last post by:
Hi, Got a litte problem here. I'm trying to create a XSLT file that will do a transformation from WordML format (MS Word XML format, see...
21
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
It is common knowledge that XHTML is better HTML and you can serve XHTML content as HTML. However, the second statement is incorrect, for various reasons; it is enough to say that the HTML...
6
by: JoeS | last post by:
I'm new to XSLT, it what our old website developer used but he has now left our company. I have been given the task of making our site output as valid XHTML as I can get it. Currently in the .XSL...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
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...

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.