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 7031483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:48:33+00:00 2026-05-28T00:48:33+00:00

<xsl:variable name=string select=’abcdefghijklmnopqrstuvwxyz’ /> I would need to convert this string to a node,

  • 0
<xsl:variable name="string" select="'abcdefghijklmnopqrstuvwxyz'" />

I would need to convert this string to a node, grouped by 5 characters, obviously the last group can be less than or equal to 5 characters depending on the input string

<node>
  <a>abcde</a>
  <a>fghij</a>
  <a>klmno</a>
  <a>pqrst</a>
  <a>uvwxy</a>
  <a>z</a>
</node>
  • 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-28T00:48:33+00:00Added an answer on May 28, 2026 at 12:48 am

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:param name="pStr" select="'abcdefghijklmnopqrstuvwxyz'" />
     <xsl:param name="pChunkSize" select="5"/>
    
     <xsl:template match="/*">
      <node>
        <xsl:call-template name="split"/>
      </node>
     </xsl:template>
    
     <xsl:template name="split">
      <xsl:param name="pStr" select="$pStr" />
      <xsl:param name="pChunkSize" select="$pChunkSize"/>
    
      <xsl:variable name="pRemLength" select="string-length($pStr)"/>
    
      <xsl:if test="$pRemLength">
       <a><xsl:value-of select="substring($pStr, 1, $pChunkSize)"/></a>
    
       <xsl:call-template name="split">
        <xsl:with-param name="pStr" select="substring($pStr, $pChunkSize+1)"/>
        <xsl:with-param name="pChunkSize" select="$pChunkSize"/>
       </xsl:call-template>
      </xsl:if>
    
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on any XML document (not used), produces the wanted, correct result:

    <node>
       <a>abcde</a>
       <a>fghij</a>
       <a>klmno</a>
       <a>pqrst</a>
       <a>uvwxy</a>
       <a>z</a>
    </node>
    

    Explanation: Primitive recursion with no string length as the stop condition, and with each recursion step producing the next chunk and cutting it from the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code selects the nodes, I want to work on...: <xsl:variable name=rootTextpageNode select=$currentPage/ancestor-or-self::node [@level
The relevant parts of the code: <xsl:variable name=apos>'</xsl:variable> <xsl:variable name=and select='&#039;' /> <xsl:value-of select=translate(products_name/node(),$and,$apos)/>
What I have is following: <xsl:variable name=myvar select=.//spss:category[((not @varName) or @varName=$colVarName) and @text=$series]/spss:cell/@text/> What
The following works for me: <xsl:variable name=core select=document('CoreMain_v1.4.0.xsd') /> <xsl:variable name=AcRec select=document('AcademicRecord_v1.3.0.xsd') /> <xsl:template
I need to select the position of a following sibling via XSL. This is
I am using xslt1.0. My input is <xsl:variable name=string>width:12pt;border-width:13pt</xsl:variable> I want to replace the
I have <xsl:for-each select=ancestor-or-self::*> <xsl:variable name=expression select=name() ></xsl:variable> </xsl:for-each> below I have href and
Given <xsl:variable name=datePrecision as=element()*> <p>Year</p> <p>Month</p> <p>Day</p> <p>Time</p> <p>Timestamp</p> </xsl:variable> The expression $datePrecision[5] returns
The following isn't working as intended: <xsl:template match=xs:complexType> <xsl:param name=prefix /> <xsl:if test=$prefix='core'> <xsl:variable
How can I retrieve the position of the current Para? <xsl:template match=Para> <xsl:variable name=PositionInDocument

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.