Re: Referencing an attribute which is an entity

Subject: Re: Referencing an attribute which is an entity
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 17 Nov 2000 16:39:50 +0000

> i have an entity named "logo" which refers to a gif file. it has the
> appropriate <!NOTATION> in the corresponding dtd. however, i just can't manage 
> to output the contents of the entity (via the attribute 'source' from my xml 
> element).
> i am trying to write <img src=".... and then chuck my attribute value in but 
> the parser (IE5) just complains. i have tried using &quot; &lt; &gt; etc for 
> encoding but i still cant get it to work...

I *think* that you're after unparsed-entity-uri().  For example, if I
have the following XML file:

--- test.xml ---
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<!DOCTYPE image [
<!ENTITY logo SYSTEM 'logo.gif' NDATA GIF>
<!ATTLIST image
  source  ENTITY #IMPLIED>
<image source="logo" />

The 'img' element I want to create has a 'src' equal to the file
location of the 'logo' entity.  In other words, I want to create
something like:

  <img src="logo.gif" />

Getting the file location of the logo entity involves:


or, given you want to get this from the 'source' attribute of the


To put that value into the 'src' attribute of an 'img' element, use
either xsl:attribute:

    <xsl:attribute name="src">
      <xsl:value-of select="unparsed-entity-uri(/image/@source)" />

or an attribute value template:

  <img src="{unparsed-entity-uri(/image/@source)}" />

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread