3 users online. Create an account or sign in to join them.Users

Search

What would be the best way to include the meta keywords tag in the head section of an XSLT file? My difficulty is that I need to include the value of each keyword insite an html tag attribute.

My template

<xsl:template match="data/settings/entry/website-keywords">
    <xsl:for-each select="item">
        <xsl:value-of select="."/>
        <xsl:text>, </xsl:text>
    </xsl:for-each>
</xsl:template>

called in the master file

<meta name="keywords" content="{data/settings/entry/website-keywords}"/>

renders this code in the browser

<meta name="keywords" content="&#10;&#9;&#9;&#9;&#9;fusce&#10;&#9;&#9;&#9;&#9;sem&#10;&#9;&#9;&#9;&#9;tortor&#10;&#9;&#9;&#9;&#9;venenatis&#10;&#9;&#9;&#9;&#9;vestibulum&#10;&#9;&#9;&#9;" />

I can't figure out why I'm getting these extra characters

#10;&#9;&#9;&#9;&#9;

Could anyone help me please?

The {data/settings/entry/website-keywords} syntax isn't calling your template but instead simply doing a value-of. To call your template you have to do something like

<meta name="keywords">
    <xsl:attribute name="content">
        <xsl:apply-templates select="data/settings/entry/website-keywords" />
    </xsl:attribute>
</meta>

Thank you phoque. You are right. This works

  <xsl:if test="position() != last()">, </xsl:if>

Great, thanks kalvind.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details