Search

A new XSLT utility, “HTML Truncate” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

When I use <xsl:apply-templates select="introtekst" mode="truncate"/> it doesn’t work and also when I use <xsl:value-of select="introtekst" mode="truncate"/> I don’t see a truncate of the text.

This is my xml file

<entry id="18">
    <introtekst>Dit is een blog met plaatje. Nulla egestas magna eget elit lobortis pretium. In nulla risus, euismod quis semper eu, suscipit luctus    justo. Quisque vehicula ultricies lectus ac porta.</introtekst>
</entry>

Replace <xsl:template match="body" mode="truncate"> with <xsl:template match="introtekst" mode="truncate"> and try again using <xsl:apply-templates select="introtekst" mode="truncate" />.

Can we see your XML?

Hi guys,

Im stuck with the same problem as whgdesign was or is. I don’t know if he find the solution yet? If you did, I would like to see it :)

this is my call

<xsl:value-of select="data/resorts/entry/resort-description" mode="truncate"/>

it loads the whole entry, which means I have the correct pad but it doesn’t truncate.

I tried Nils’s solution but it gave me a XSLT processing error…. Can someone give a good example of how to use this utility?

thanks

Sandor

I think you should use

<xsl:apply-templates select="data/resorts/entry/resort-description" mode="truncate"/>

<xsl:value-of /> copies the value straight away without giving you the opportunity to apply any special templates or functions (wich the truncation-utility is) first.

I know, but that doesn’t work at all…. I need a simple example cause I don’t know what im doing wrong

thanks

Have you set the extra exsl namespace?

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl">

I tried Nils’s solution but it gave me a XSLT processing error…

What errors are you seeing?

no errors, it just doesn’t work… I tried what you said phoque and used the apply templates, but still it doesn’t work. If i remove the “mode=”truncate”, it shows the whole entry, so the path must be working fine. But when I add the truncate mode, it doesn’t work anymore.

I also added the extension element klaftertief gave me, also no luck :(

Maybe it has something to do with Symphony 2.1.1?

Maybe it has something to do with Symphony 2.1.1?

Probably not. Did you remember to include the utility in your XSLT?

If that doesn’t fix it can you show us your XML and your XSLT?

I’ve tried all of the solutions, but with no result, nothing is showed when I use the mode="truncate".

This is my XML:

<data>
    <events />
    <blog-home>
        <section id="5" handle="blog">Blog</section>
        <entry id="19">
            <afbeelding-weergeven path="/uploads/pictures/blog">
                <item size="45 KB">ist2_10886447-racing-bicycle-isolated-on-white.jpg</item>
            </afbeelding-weergeven>
            <introtekst>Tincidunt varius sequi, integer magna ac, donec curabitur. Rhoncus sed. Lectus vitae augue, mauris tincidunt. Ut nec fermentum, dolor vestibulum. Nunc neque tincidunt, non dictumst tempus. Et id, duis sit arcu, felis porta donec. Proin tincidunt. Tincidunt varius sequi, integer magna ac, donec curabitur. Rhoncus sed. Lectus vitae augue, mauris tincidunt.</introtekst>
            <titel handle="wat-zullen-we-eens-bloggen">Wat zullen we eens bloggen?</titel>
        </entry>
    </blog-home>
</data>

And this is my XSLT:

<xsl:template match="data">
    <div>
        <h3><xsl:value-of select="blog-home/entry/titel"/></h3>
        <p><xsl:apply-templates select="blog-home/entry/introtekst" mode="truncate" /></p>
    </div>
</xsl:template>

The XSLT above is the one inside my home.xsl.
I’ve include inside my home.xsl the master.xsl and inside the master I include truncate.xsl.

Oh, what’s happening here? Two people with the same problem… Maybe we should split them up into two separate threads and keep this one here for its original purpose (general discussion and announcements).

Okey, I opened a new issue

I’ll continue here with my problem. The issue I’ve opended isn’t relevant anymore.

Quote of designermonkey

with issues like this, always try starting your xpath from the data node

/data/blog-home/entry/titel

/data/blog-home/entry/introtekst

I’ve tried that, the same problem continues. With the mode="truncate" I didn’t see the introtekst and without the mode="tuncate" I see the introtekst.

Quote of designermonkey

(Can’t edit comment)

Also try

/data/blog-home/entry/introtekst/text()

Have you changed the match attribute of the template from body to introtekst?

I know it’s mentioned in the other post, but just checking.

When I try <xsl:apply-templates select="/data/blog-home/entry/introtekst/text()" mode="truncate" />
I see the text, but it is the full length of the introtekst and not a truncated text.

Inside the truncate.xsl I’ve changed the match value body to introtekst.

<xsl:template match="introtekst" mode="truncate">
    <xsl:param name="limit" select="10"/>
    <xsl:param name="suffix" select="'&#8230;'"/>

    <xsl:variable name="body">
        <xsl:copy-of select="*"/>
    </xsl:variable>

    <xsl:apply-templates select="exsl:node-set($body)/*" mode="truncate">
        <xsl:with-param name="limit" select="$limit"/>
        <xsl:with-param name="suffix" select="$suffix"/>
    </xsl:apply-templates>

</xsl:template>

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