Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1096289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:15:43+00:00 2026-05-17T00:15:43+00:00

I’m trying to create a report in an email and email daemons chop lines

  • 0

I’m trying to create a report in an email and email daemons chop lines if they’re over ~ 2040 characters long.
I’m using XSLT to build the email report and I need to break up these lines but I still need the link to work.

<xsl:variable name="encoded_url">
    <xsl:value-of select="saxon:string-to-base64Binary(concat(PROTOCOL,'://',URL),'UTF8')" xmlns:saxon="http://saxon.sf.net/"/>
</xsl:variable>
<dd style="{$style-dd}">
    <a title="View URL"
        href="{$baseHref}report?url={$encoded_url}" style="{$style-links}">
        <xsl:call-template name="break-url" >
            <xsl:with-param name="url" select="URL" />
            <xsl:with-param name="length">75</xsl:with-param>
            <xsl:with-param name="lines">999</xsl:with-param>
        </xsl:call-template>
    </a>

This isn’t my code and I’m not real familiar with XSL but I’ve searched on here and on the web and I’m not really seeing an awesome solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:15:44+00:00Added an answer on May 17, 2026 at 12:15 am

    This XPath 2.0 expression:

    string-join(for $line in tokenize(line,'&#xA;'),
                    $length in string-length($line)
                return if ($length > $pMaxLength)
                       then substring(replace($line,
                                              concat('(.{1,',
                                                     $pMaxLength,
                                                     '})'),
                                              '$1&#xA;'),
                                      1,
                                      $length + ceiling($length div $pMaxLength) -1)
                       else $line,
                '&#xA;')
    

    For test, this input:

    <line>
    line1
    line2 line2 line2 line2
    line3line3
    line4line4
    line5line5line5line5line5
    </line>
    

    With this XSLT 2.0 stylesheet:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
        <xsl:param name="pMaxLength" select="10"/>
        <xsl:template match="/">
            <xsl:value-of
             select="string-join(
                         for $line in tokenize(line,'&#xA;'),
                             $length in string-length($line)
                         return if ($length > $pMaxLength)
                                then substring(replace($line,
                                                       concat('(.{1,',
                                                              $pMaxLength,
                                                              '})'),
                                                       '$1&#xA;'),
                                               1,
                                               $length +
                                               ceiling($length div $pMaxLength) - 1)
                                else $line,
                         '&#xA;')"/>
        </xsl:template>
    </xsl:stylesheet>
    

    Output:

    line1
    line2 line
    2 line2 li
    ne2
    line3line3
    line4line4
    line5line5
    line5line5
    line5
    

    Just in case, this XSLT 1.0 stylesheet:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
        <xsl:template match="line/text()" name="lines">
            <xsl:param name="pString" select="."/>
            <xsl:param name="pMaxLength" select="10"/>
            <xsl:choose>
                <xsl:when test="contains($pString,'&#xA;')">
                    <xsl:call-template name="lines">
                        <xsl:with-param name="pString" 
                         select="substring-before($pString,'&#xA;')"/>
                        <xsl:with-param name="pMaxLength" 
                         select="$pMaxLength"/>
                    </xsl:call-template>
                    <xsl:call-template name="lines">
                        <xsl:with-param name="pString" 
                         select="substring-after($pString,'&#xA;')"/>
                        <xsl:with-param name="pMaxLength" 
                         select="$pMaxLength"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="concat(substring($pString,1,$pMaxLength),
                                                 '&#xA;')"/>
                    <xsl:apply-templates 
                     select="current()[string-length($pString) > $pMaxLength]">
                        <xsl:with-param name="pString"
                         select="substring($pString,$pMaxLength+1)"/>
                        <xsl:with-param name="pMaxLength" select="$pMaxLength"/>
                    </xsl:apply-templates>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.