473,748 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:crea tor" /></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:styleshe et 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:0 px;height:{imag e/height}px;width :{image/width}px;" /></a>

<div>
<div><i><a class="rssfeede rs" href="{link}">< xsl:value-of
select="descrip tion" /></a></i></div>
<div><i><xsl:va lue-of select="lastBui ldDate" /></i></div>
</div>

<p />

<xsl:for-each select="item">
<div><a href="{link}" target="_blank" ><b><xsl:valu e-of select="title"
/></b></a></div>
<div><i><xsl:va lue-of select="dc:crea tor" /></i></div><!-- LINE OF
INTEREST -->
<div><i><xsl:va lue-of select="pubDate " /></i></div><p />
</xsl:for-each>

<p />

</div>

</xsl:template>

</xsl:stylesheet>
Nov 12 '05 #1
3 2727
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.dt d"
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.dt d">
Steven
Founder, http://venturetogether.com

"Grant Harmeyer" <gn*********@ho tmail.com> wrote in message
news:ev******** ******@TK2MSFTN GP10.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:crea tor" /></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:styleshe et 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:0 px;height:{imag e/height}px;width :{image/width}px;" /></a>

<div>
<div><i><a class="rssfeede rs" href="{link}">< xsl:value-of
select="descrip tion" /></a></i></div>
<div><i><xsl:va lue-of select="lastBui ldDate" /></i></div>
</div>

<p />

<xsl:for-each select="item">
<div><a href="{link}" target="_blank" ><b><xsl:valu e-of select="title" /></b></a></div>
<div><i><xsl:va lue-of select="dc:crea tor" /></i></div><!-- LINE OF
INTEREST -->
<div><i><xsl:va lue-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.or g 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:crea tor" /> type of syntax?

"Steven Livingstone" <s.***********@ nospam.btintern et.com> wrote in message
news:eq******** ******@TK2MSFTN GP11.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.dt d" 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.dt d">
Steven
Founder, http://venturetogether.com

"Grant Harmeyer" <gn*********@ho tmail.com> wrote in message
news:ev******** ******@TK2MSFTN GP10.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:crea tor" /></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:styleshe et 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:0 px;height:{imag e/height}px;width :{image/width}px;" /></a>

<div>
<div><i><a class="rssfeede rs" href="{link}">< xsl:value-of
select="descrip tion" /></a></i></div>
<div><i><xsl:va lue-of select="lastBui ldDate" /></i></div>
</div>

<p />

<xsl:for-each select="item">
<div><a href="{link}" target="_blank" ><b><xsl:valu e-of

select="title"
/></b></a></div>
<div><i><xsl:va lue-of select="dc:crea tor" /></i></div><!-- LINE OF
INTEREST -->
<div><i><xsl:va lue-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*********@ho tmail.com> wrote in message
news:#M******** ******@TK2MSFTN GP12.phx.gbl...
Ok, that worked fine and according to validator.w3.or g 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:crea tor" /> type of syntax?

"Steven Livingstone" <s.***********@ nospam.btintern et.com> wrote in message news:eq******** ******@TK2MSFTN GP11.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.dt d"
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.dt d">
Steven
Founder, http://venturetogether.com

"Grant Harmeyer" <gn*********@ho tmail.com> wrote in message
news:ev******** ******@TK2MSFTN GP10.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:crea tor" /></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:styleshe et 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:0 px;height:{imag e/height}px;width :{image/width}px;"

/></a>
<div>
<div><i><a class="rssfeede rs" href="{link}">< xsl:value-of
select="descrip tion" /></a></i></div>
<div><i><xsl:va lue-of select="lastBui ldDate" /></i></div>
</div>

<p />

<xsl:for-each select="item">
<div><a href="{link}" target="_blank" ><b><xsl:valu e-of

select="title"
/></b></a></div>
<div><i><xsl:va lue-of select="dc:crea tor" /></i></div><!-- LINE OF INTEREST -->
<div><i><xsl:va lue-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
1909
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 this request might be against the spirit of XML in general, but the reason I'm trying to do this is that I want to use XSLT for simple generation of XHTML. Basically I want the page's contents in external files, then I want to include them into a...
2
6089
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="..." .....></img> The output is always :
4
3170
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 particular tag, and was also pretty sure that they wanted the following <ul><li>two</li><li>items</li></ul> to appear as a list. To make matters worse <sarcastic>how could this be worse?</sarcastic>, the XHTML can be mixed with our own tags.</note>
1
3108
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 Transformer convert that via XSLT to valid XSL-FO. So I define a SAXReader which fires the SAX Events for the Java Object. This works fine and the Transformation to PDF is ok. However, I have one object which contains an XHTML String and the tags
6
1822
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 you aren't just limited to your XML data, but can transform a whole web page? Any assistance would be really appreciated. Cheers,
4
1802
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 http://rep.oio.dk/Microsoft.com/officeschemas/welcome.htm) to a reasonably clean (X)HTML format. (The reason being that, combined with some PHP scripting it should be possible to store the embedded images, which is pretty neat).
21
4608
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 validator does not tolerate XML-style empty tags. It seems serving XHTML to the browser is of no advantage and can cause serious problems if the browser does not understand the difference. This raises the question of downgrading XHTML to HTML. I could...
6
2390
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 files I write self-closing tags like <br/> but in the output XHTML they come out as <br> and therefore the page doesn't validate. This happens for other self-closing tags like <img src=""/> too. I don't really know XSLT so I don't know how I can fix...
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.