paetje Posted April 5, 2006 Share Posted April 5, 2006 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 More sharing options...
insanity381 Posted April 5, 2006 Share Posted April 5, 2006 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 More sharing options...
paetje Posted April 5, 2006 Author Share Posted April 5, 2006 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 More sharing options...
paetje Posted April 5, 2006 Author Share Posted April 5, 2006 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 More sharing options...
Little Goat Posted April 5, 2006 Share Posted April 5, 2006 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 More sharing options...
insanity381 Posted April 6, 2006 Share Posted April 6, 2006 hmmm...I've tried this for an image, still doesn't work.files at:http://trizle.mybesthost.com/images/googlegroups.gifhttp://trizle.mybesthost.com/index.xslhttp://trizle.mybesthost.com/group.xmlplez download files, test, try, help! cheers in advance... Link to comment Share on other sites More sharing options...
Little Goat Posted April 6, 2006 Share Posted April 6, 2006 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 More sharing options...
paetje Posted April 7, 2006 Author Share Posted April 7, 2006 Thanx Goat, works just fine! Link to comment Share on other sites More sharing options...
paetje Posted April 7, 2006 Author Share Posted April 7, 2006 Does this also works for objects like Flash movies? Link to comment Share on other sites More sharing options...
paetje Posted April 7, 2006 Author Share Posted April 7, 2006 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 More sharing options...
insanity381 Posted April 7, 2006 Share Posted April 7, 2006 I don't think your image exists!I'm pretty damn sure it exists, maybe it's trying to stop hot-linking or something...BTW, sorry to be dumb, but do I need an apply-templates or something somewhere, I just don't know where? Link to comment Share on other sites More sharing options...
franceav Posted April 10, 2006 Share Posted April 10, 2006 <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 More sharing options...
boen_robot Posted April 10, 2006 Share Posted April 10, 2006 (edited) Т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 April 23, 2006 by boen_robot Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now