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

Discussion in 'XML' started by j erickson, Jun 9, 2004.

  1. j erickson

    j erickson Guest

    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:eek:utput 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>
     
    j erickson, Jun 9, 2004
    #1
    1. Advertising

  2. Re: xsl for an rdf file, src attribute won't create correct linkto image file

    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.)
     
    Johannes Koch, Jun 9, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter

    <txt src= ...> equivalent of <img src= ...>

    Steve Richter, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,098
    Laurent Bugnion
    Feb 9, 2006
  2. Greg Johnson
    Replies:
    4
    Views:
    3,080
  3. Replies:
    1
    Views:
    1,624
    Alex Hunsley
    Mar 23, 2007
  4. pheadxdll
    Replies:
    16
    Views:
    3,687
    Neredbojias
    Jun 6, 2007
  5. Soren Vejrum
    Replies:
    4
    Views:
    616
    Lasse Reichstein Nielsen
    Jul 5, 2003
Loading...

Share This Page