homepage Welcome to WebmasterWorld Guest from 54.204.94.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
I Need Help in one function!
xsl function
golfinhu



 
Msg#: 4171580 posted 3:17 pm on Jul 16, 2010 (gmt 0)

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!

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved