Search

Hi Folks

last day I try to transform this:

<entry id="20">
    <newtags>
        <item id="9" handle="webdesign" section-handle="tags" section-name="Tags">webdesign</item>
        <item id="10" handle="html-css" section-handle="tags" section-name="Tags">html/css</item>
        <item id="17" handle="typo3" section-handle="tags" section-name="Tags">typo3</item>
    </newtags>
    <title handle="ffmtipptopp">ffmtipptopp</title>
</entry>

into this:

<div class="cols1 webdesign html-css typo3">
 some infos here 
</div>

tried it with:

<div class="cols1 {newtags/child::*/@handle}">
 some infos here
</div>

but it doesent really helps. Can somebody help?

Perhaps

    <div>
        <xsl:attribute name="class">
            <xsl:apply-templates select="newtags/item" />
        </xsl:attribute>

        some infos here
    </div>

...

<xsl:template match="newtags/item">
    <xsl:value-of select="@handle" />
</xsl:template>

To make sure there are spaces between each class, you might need to do something like this:

<xsl:template match="/">
    <xsl:apply-templates select="entry" />
</xsl:template>

<xsl:template match="entry">
    <xsl:param name="tags-classes">
        <xsl:apply-templates select="newtags/item" />
    </xsl:param>
    <div class="cols1 {$tags-classes}">
        some infos here 
    </div>
</xsl:template>

<xsl:template match="newtags/item">
    <xsl:value-of select="@handle" /><xsl:if test="position() != last()"><xsl:text> </xsl:text></xsl:if>
</xsl:template>

Yeah! Thats it! Thank your for the help!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details