You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Bennett <be...@glengroup.com> on 2002/07/18 23:34:21 UTC

Xml and images - the next step

Hi All,

	First off, thank you so much for the feedback I received on the 
topic. Every response really helped in various ways.

	Now that the image is working in Netscape 6, the next step is:

	- How do I get the same thing to work in Internet Explorer 5.1 for 
Mac OS X. (I was able to get the same thing to work on IE on Windows)?


	Also,
	
	- Is there a more efficient way to do the same thing (make an image 
appear using xml/xslt)?

	If so, could someone please show me how?


Again, thank you so much.

Bennett

Here's the latest version of the code I posted before:

image.xml
---------------------------
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="image.xsl" ?>
<!-- Here, I want to figure out the best way to get an image from xml -->

<images>
	<image>
		<filename>image.jpg</filename>
	</image>
</images>
---------------------------



image.xsl
---------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:variable name="source">
	<!-- <xsl:value-of select="./filename" /> -->
	<xsl:value-of select="images/image/filename" />
</xsl:variable>

<xsl:template match="images">
	<html>
	<body>
		<xsl:apply-templates/>
	</body>
	</html>
</xsl:template>

<xsl:template match="//image">
	<div style="position:absolute;top:100px;left:100px;border:1px solid 
#000000;">
	Before Image
	<img src="{$source}" width="50" height="50" border="1" />	
	After Image
	</div>
</xsl:template>
</xsl:stylesheet>
---------------------------


Re: Xml and images - the next step

Posted by Xavier Renard <Xa...@ulg.ac.be>.
> Hi All,

Hi Bennett
>
>
> Now that the image is working in Netscape 6, the next step is:
>
> - How do I get the same thing to work in Internet Explorer 5.1 for
> Mac OS X. (I was able to get the same thing to work on IE on Windows)?
>
I don't know MAC OS X at all but it's html related (or I miss something here
???)

> - Is there a more efficient way to do the same thing (make an image
> appear using xml/xslt)?

I don't know if it is more effecient but you can do it that way:


 <xsl:element name="IMG">
<xsl:attribute name="src"><xsl:value-of select="myImage"/></xsl:attribute>
<xsl:attribute name="width">40</xsl:attribute>
<xsl:attribute name="height">80</xsl:attribute>
 </xsl:element>

or that way if you have several images wih  same attributes:

.....
 <xsl:element name="img" use-attribute-sets="myAttributes"/>
 <xsl:apply-templates/>
        </BODY>
        </HTML>
</xsl:template>

<xsl:attribute-set name="myAttributes">
        <xsl:attribute name="src">image.jpg</xsl:attribute>
        <xsl:attribute name="width">40</xsl:attribute>
        <xsl:attribute name="height">80</xsl:attribute>

        </xsl:attribute-set>
</xsl:stylesheet>

Regards

Xavier