Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert an image 1

Status
Not open for further replies.

karlito

Technical User
Jun 28, 2001
8
GB
Hi,

I'm working on an XSL document and trying to display an image which target is available in an XML document.

Any ideas on how I could display that?

that would only display the target:
<xsl:value-of select=&quot;IMAGE&quot;/>

Is there something like <img src=&quot;XMLLINK&quot;/>?

Thanks for your help.

 
I thought the most logical way was to manipulate the HTML attribute &quot;IMG SRC=...&quot; in an XSL stylesheet, but I got bunk.

I was trying something like this in an XSL document:

<img <xsl:attribute name=&quot;src&quot;><xsl:value-of select=&quot;IMAGE&quot;/></xsl:attribute>/>

If you can think of something better (and something that actually works, please let me know!

jason@kuam.com

 
This is one way. Maybe not the coolest, but it works:

<xsl:text disable-output-escaping=&quot;yes&quot;>
<img border=&quot;0&quot; src=&quot;test.jpg&quot;>
</xsl:text>


Regards,

Oliver Talens
*****************************
Abyss I.T. Solutions
Mathildastraat 36B
4901 HC Oosterhout


tel: +31 (0)162-439809
fax: +31 (0)162-439882
O.Talens@Abyss.nl
*****************************
 
Sorry guys but none of these worked.

The target of the photo is in an element withing an XML document, which various contents I'm displaying with the use of an XSL document. I'm trying to display this image automatically with the use of
<xsl:value-of select=&quot;IMAGE&quot;/>, however what I cant do is use <img src=&quot;<xsl:value-of select=&quot;IMAGE&quot;/>&quot; />.

Any suggestions?

Thanks
 
I've seen a couple of different ways, but nothing which is workable in a realistic, professional environment. &quot;XML For Dummies&quot; uses an example of inserting an image by setting the image filename as the &quot;background-image&quot; property in CSS. But, that comes out no good.

As long as the data included in the XML is the URL or absolute path if on a LAN to the image, this should be OK.

Check this out from:
.......................
As with HTML links can be used to include images or diagrams into a document. The inclusion of images into a book structure is something that could be implemented if time allows. The main problem with inserting images into a document is that the image files cannot actually be incorporated into the XML data file and have to be held separately and linked in at the point they are to appear. This means that the inclusion of images needs to be thought about a lot to come up with a sensible way of using them.
................

When I was working wity MSNBC.COM on a publishing tool, they allowed for the URLs of graphics file to be used, and the graphics would be displayed. However, this takes tricky DTD programming. (In the news biz, there's already a standing DTD format, called News Industry Text Format (NITF)).

Also, check out the &quot;C.23&quot; section of this page:

I'm looking...
 
I actually had this archived on nmy PC, so this is the XML document which conforms to the aforementioned NITF DTD ( It allows for graphics to be placed on pages, and this is how mayn of the big boys do it in the news biz. Pay particular attention to the <MEDIA-REFERENCE> tages about halfway through the document....that's where the image magic lies:

**************************************************
STORY1234.XML
**************************************************

<?xml version=&quot;1.0&quot; ?>
<nitf>
<head>
<docdata>
<doc-id id=&quot;A030701b&quot; />
</docdata>
<pubdata id=&quot;KUAM&quot; position.section=&quot;news&quot; position.sequence=&quot;1&quot; ex-ref=&quot; </head>

<body>
<body.head>
<headline>
<hl1>Runway lights fail at airport</hl1>
</headline>
<byline>
<person>
<name.given>by Yanna</name.given>
<name.family>Person</name.family>
</person>
</byline>
<dateline>
<location>
<city>Tamuning</city>
<state>Guam</state>
<region>Pacific</region>
<country>USA</country>
</location>
<story.date><![CDATA[March 7]]></story.date>
</dateline>
<abstract>
<p><![CDATA[As Continental Flight 862 began its descent into the Guam International Airport Wednesday night, the aircrew suddenly found themselves without ground assistance]]></p>
</abstract>
</body.head>
<body.content>
<block>
<!--Main, Cover and Mugshot Image Elements-->
<media media-type=&quot;image&quot; >
<media-metadata name=&quot;main picture&quot; />
<media-reference data-location=&quot; width=&quot;300&quot; height=&quot;225&quot; mime-type=&quot;jpeg&quot; alternate-text=&quot;A power surge at GIAA caused a Continental flight to delay landing for nearly half an hour (videography by Pete Leota)&quot;></media-reference>
<media-caption>A power surge at GIAA caused a Continental flight to delay landing for nearly half an hour (videography by Pete Leota)</media-caption>
<media-producer>Videography by Pete Leota</media-producer>
</media>
<media media-type=&quot;image&quot;>
<media-metadata name=&quot;cover picture&quot;/>
<media-reference data-location=&quot; width=&quot;200&quot; height=&quot;200&quot; mime-type=&quot;jpeg&quot; alternate-text=&quot;A power surge at GIAA caused a Continental flight to delay landing for nearly half an hour (videography by Pete Leota)&quot;></media-reference>
<media-caption>A power surge at GIAA caused a Continental flight to delay landing for nearly half an hour (videography by Pete Leota)</media-caption>
<media-producer>Videography by Pete Leota</media-producer>
</media>
</block>

<p lede=&quot;true&quot;>As Continental Flight 862 began its descent into the Guam International Airport Wednesday night, the aircrew suddenly found themselves without ground assistance.</p>
<p id=&quot;body&quot;>
<![CDATA[The entire runway lost power to its lighting system, and the aircraft was forced to abort its landing. The power failure occurred at approximately 8:45PM, as the plane inbound from yap was scheduled to arrive. A power surge in the uninterrupted power source (UPS) caused a fire to break out in the equipment that controls airfield lighting.<P>
........................................

News8 will provide updates as this investigation continues.<P>

<I>Yanna Person is a reporter for KUAM News8</I>]]>
</p>
</body.content>
</body>
</nitf>
 
One more thing....just found this now....there's a good example of what you can do with the properties of a DTD.

Tedious....but it works!


***************************************************

<!ELEMENT media-reference (#PCDATA)>
<!ATTLIST media-reference
%common-attributes;
data-location CDATA #REQUIRED
name CDATA #IMPLIED
source CDATA #IMPLIED
mime-type CDATA #REQUIRED
coding CDATA #IMPLIED
time CDATA #IMPLIED
time-unit-of-measure CDATA #IMPLIED
outcue CDATA #IMPLIED
source-credit CDATA #IMPLIED
copyright CDATA #IMPLIED
alternate-text CDATA #IMPLIED
height NMTOKEN #IMPLIED
width NMTOKEN #IMPLIED
units (pixels) &quot;pixels&quot;
imagemap CDATA #IMPLIED
noflow (noflow) #IMPLIED
>
<!--
Element media-reference
Partial description Reference to a media object.
Full description Points to any object, such as photo, audio, video and text; or to executable files.

Attribute name id
Description Unique identifier for the element.
Attribute name class
Description An open placeholder for categorization.
Attribute name style
Description An open placeholder for reference by an external stylesheet.
Attribute name lang
Description Language for the element. Uses en-US (per ISO 639 and 3166).
Attribute name dir
Description Direction - rtl (right-to-left) or ltr - of language rendering.
Attribute name data-location
Description Location of data other than a URN, such as a absolute server path.
Attribute name name
Description Alternate name or description of the object.
Attribute name source
Description URL for external media file. !!
Attribute name mime-type
Description Mime-type for the external media file.
Attribute name coding
Description How the information is coded.
Attribute name time
Description Length of time that the media file plays.
Attribute name time-unit-of-measure
Description Units in which the time attribute is measured.
Attribute name outcue
Description Provides information about the spoken information that ends an audio clip.
Attribute name source-credit
Description Indicates the source of the information.
Attribute name copyright
Description Copyright owner.
Attribute name alternate-text
Description Plain-text description that can serve as a substitute for the media object.
Attribute name height
Description Height of the media object.
Attribute name width
Description Width of the media object.
Attribute name units
Description Units used for width and height. Default is pixels.
Attribute name imagemap
Description Indication for whether the media object has an affiliated imagemap.
Attribute name noflow
Description Indicates if information can flow around figure.
-->
 
Thanks Jason...

I'll try it out and let you know of the outcome. I guess the easiest thing to do at the moment is to include the image as a link for the moment. A good way of dealing with this is displaying the image on a different frame within the main frame. That seems to work pretty well.
 
maybe i'm mis-understanding what you want to do but i think you need...

<img>
<xsl:attribute name=&quot;src&quot;><xsl:value-of select=&quot;IMAGE&quot;/></xsl:attribute>
</img>
 
Thank you TOM, that works perfectly well... I'm a bit dissapointed with myself as your solution looks very useful.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top