Welcome to WebmasterWorld Guest from 54.159.44.227

Forum Moderators: httpwebwitch

Message Too Old, No Replies

I Need Help in one function!

xsl function

     

golfinhu

3:17 pm on Jul 16, 2010 (gmt 0)

5+ Year Member



Hi guys, how are you?
I need help in a very simple question!

i have this part of the code:

<!-- Searching Metatags -->        
<xsl:for-each select="document('arquivos/meta_tags.xml')">
<xsl:value-of select="metatags/tags" disable-output-escaping="yes"/>
<xsl:value-of select="metatags/layout" disable-output-escaping="yes"/>
</xsl:for-each>


As you can see, he seeks out the meta tags of an XML file using CDATA, so far so good...


But the meta description will have to have a random value, seeking another xml ... it will be a mix between the title and description, limited to 155 characters


I tried to do as follows:

I created a variable, and try to apply it within the code ...

<xsl:variable name="desc">
<xsl:for-each select="loja/produto[id_produto = $produto]">
<xsl:value-of select="title" />
<xsl:value-of select="description" />
</xsl:for-each>
</xsl:variable>



and tried to apply it at the end of the loop:

<!-- Searching Metatags-->        
<xsl:for-each select="document('arquivos/meta_tags.xml')">
<xsl:value-of select="metatags/tags" disable-output-escaping="yes"/>
<xsl:value-of select="normalize-space(substring($desc, 1, 155))" disable-output-escaping="yes"/>
<xsl:value-of select="metatags/layout" disable-output-escaping="yes"/>
</xsl:for-each>


But I can not put the variable within the meta tag, because that would end the loop, have something like:

<meta name="description" content="$desc{here is the value of $desc}" />


but gives error = /
can anyone help me?

thanks a lot!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month