By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,183 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,183 IT Pros & Developers. It's quick & easy.

xsl for an rdf file, src attribute won't create correct link to image file

P: n/a
with the following xsl and xml file, the display of the gif file with
the <image/url> tag works. However, the gif file in the <description>
tag using the name attribute "src" won't make the correct link to the
gif file. why?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:lc="http://my.netscape.com/rdf/simple/0.9/">

<xsl:output method="html" />

<xsl:template match="lc:RDF">

<HTML>
<HEAD>
<TITLE>Resource Display Page</TITLE>
</HEAD>
<BODY>
<xsl:apply-templates select="lc:item"/>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="lc:item">
<P> </P>

<a><xsl:attribute name="href"><xsl:value-of select="lc:link"
/></xsl:attribute>link
</a>

<P>image</P>
<TR>
<TD>
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of
select="lc:description/@src" /></xsl:attribute>
<xsl:attribute name="border"><xsl:value-of
select="lc:description/@border" /></xsl:attribute>
</xsl:element>
</TD>
</TR>
</xsl:template>
<xsl:template match="lc:image">

<img><xsl:attribute name="src"><xsl:value-of select="lc:url"
/></xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="lc:width"
/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="lc:height"
/></xsl:attribute>
</img>

<P>image</P>
<TR>
<TD>
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of
select="lc:description/@src" /></xsl:attribute>
<xsl:attribute name="border"><xsl:value-of
select="lc:description/@border" /></xsl:attribute>
</xsl:element>
</TD>
</TR>
</xsl:template>
</xsl:stylesheet>

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://my.netscape.com/rdf/simple/0.9/">
<channel>
<title>Dilbert</title>
<link>http://dwlt.net/tapestry/</link>
<description>Tapestry :: RSS Delivery of Web Comics</description>
</channel>
<image>
<title>Dilbert</title>
<url>http://dwlt.net/tapestry/img/tapestry.gif</url>
<link>http://dwlt.net/tapestry/</link>
<width>88</width>
<height>31</height>
</image>
<item>
<title>Dilbert for 09 Jun 2004</title>
<link>http://www.dilbert.com/comics/dilbert/archive/dilbert-20040609.html</link>
<guid isPermaLink="false">http://www.dilbert.com/comics/dilbert/archive/dilbert-20040609.html</guid>
<description>
&lt;img src="http://www.dilbert.com/comics/dilbert/archive/images/dilbert2004067240609.gif"
border="0" /&gt;
</description>
</item>
<item>
<title>Dilbert for 08 Jun 2004</title>
<link>http://www.dilbert.com/comics/dilbert/archive/dilbert-20040608.html</link>
<guid isPermaLink="false">http://www.dilbert.com/comics/dilbert/archive/dilbert-20040608.html</guid>
<description>
&lt;img src="http://www.dilbert.com/comics/dilbert/archive/images/dilbert2061008040608.gif"
border="0" /&gt;
</description>
</item>
<item>
<title>Dilbert for 07 Jun 2004</title>
<link>http://www.dilbert.com/comics/dilbert/archive/dilbert-20040607.html</link>
<guid isPermaLink="false">http://www.dilbert.com/comics/dilbert/archive/dilbert-20040607.html</guid>
<description>
&lt;img src="http://www.dilbert.com/comics/dilbert/archive/images/dilbert21220170040607.gif"
border="0" /&gt;
</description>
</item>
</rdf:RDF>
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
j erickson wrote:
with the following xsl and xml file, the display of the gif file with
the <image/url> tag works. However, the gif file in the <description>
tag using the name attribute "src" won't make the correct link to the
gif file. why? <xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of
select="lc:description/@src" /></xsl:attribute>
<xsl:attribute name="border"><xsl:value-of
select="lc:description/@border" /></xsl:attribute>
</xsl:element>


1. the description element from the namespace prefixed with lc has no
src attribute
2. there is no img element in the description element, just text
(&lt;img ... /&gt; is _not_ <img ... />).
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.