[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
doctype image
Dan,

> 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 [
<!NOTATION GIF SYSTEM "gif.doc">
<!ENTITY logo SYSTEM 'logo.gif' NDATA GIF>
<!ELEMENT image EMPTY>
<!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:

  unparsed-entity-uri('logo')

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

  unparsed-entity-uri(/image/@source)

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

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

or an attribute value template:

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

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.