Jump to content

pictures with XSL-T


paetje

Recommended Posts

I made an element

<picture src="path.jpg" alt="text">bla</picture>

Now I want to show this picture on my page. I can find the picture and show my text "bla". But how must I load the picture?

Link to comment
Share on other sites

I'm still trying to learn how to do this, but you'd need another <xsl:template> thingy-magigy somewhere, as well as <xsl:apple-templates> so it would transform <picture> into <img> for you. Do reply, knowladgable people, I want to know how to do this as well! :) BTW, i want to transform <rule /> into <hr /> and <newpara /> into <p />, please. cheers in advance.

Link to comment
Share on other sites

I have this

	<xsl:template match="picture">  <xsl:value-of select="."  /> <!-- gives me "bla" -->  <img src="." /> <!-- here must my patch be attatched  -->	</xsl:template>

Don't know if its possible this way. The path of my picture must be universal. So when I have more pictures this statement still works.

Link to comment
Share on other sites

and I found it again:

XSL<xsl:variable name="image-dir">/images</xsl:variable><xsl:template match="photograph"><img src="{$image-dir}/{href}" width="{size/@width}"/></xsl:template>XML<photograph>  <href>headquarters.jpg</href>  <size width="300"/></photograph>This would be like this in XHTML<img src="/images/headquarters.jpg" width="300"/>

Link to comment
Share on other sites

yes you can do it the first way:

<xsl:template match="picture"><xsl:value-of select="."/><xsl:variable name="src" select="@src"/><img src="{$src}"/></xsl:template>

that should do it!LG

Link to comment
Share on other sites

try putting the path in one variable. if your going to do it like you are, make href a value too.I just clicked on the image link and it goes to 100webspace.com or something. I'm presuming that's your host, but I don't think your image exists!LG

Link to comment
Share on other sites

I worked it out and it works fine alsoXSL

	<xsl:template match="object">  <xsl:value-of select="."/>  <xsl:variable name="src" select="@src"/>  <xsl:variable name="width" select="@width"/>  <xsl:variable name="height" select="@height"/>  <xsl:variable name="class" select="@class"/>  <embed src="../Flash/{$src}" width="{$width}" height="{$height}" class="{$class}"/>	</xsl:template>

XML

<object src="team.swf" width="550" height="350" class="team"></object>

Link to comment
Share on other sites

<xsl:template match="picture"><xsl:value-of select="."/><xsl:variable name="src" select="@src"/><img src[COLOR=red]="{$src}"/[/COLOR]></xsl:template>

what does "{$src}" mean?is that a server side scripting or programing?i just don't get the $ symbol,i'm very new to this area and would very appreciateif somebody help me out:)
Link to comment
Share on other sites

Тhe $ sign is used to access variables and parameters. Or to be exact- it specifies that what you adress is a variable or parameter. The name of the variable is written right after it so everything the variable returns in the end is written at that spot. Parenthesis are used around the sign and the name when the variable is called inside an attribute's value.Scince you can't have a <xsl:value-of> inside an attribute's value, but you can have a variable applyed inside, the <xsl:variable> is the only possible tecnique when it comes to empty elements such as <img />. In other cases, you could also use the <xsl:attribute>, but even then, the <xsl:variable> method (used above) remains better in most cases.[edit] I did recenly saw a usage of the <xsl:element> element with a child of <xsl:attribute> which is a possible solution too, but this method does remain more comfortable. [/edit]

Edited by boen_robot
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...