Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Falch Madsen 70 posts 92 karma points
    Nov 09, 2010 @ 11:06
    Michael Falch Madsen
    0

    String Match

    I'm trying to make a TOC xslt but i dont know much about regular expressions.

    On the document type i have 2 fields where i put start and end letter and i would like my xslt to fetch all pages beginning with a letter between start and end? Can this be done?

     

     

    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <xsl:if test="Exslt.ExsltRegularExpressions:match(@nodeName, '[a-Z]')">
        <li>
          <a href="{umbraco.library:NiceUrl(@id)}">      
            <xsl:value-of select="@nodeName"/>
          </a>
        </li>  
      </xsl:if>
    </xsl:for-each>
    </ul>

  • Michael Falch Madsen 70 posts 92 karma points
    Nov 09, 2010 @ 11:51
    Michael Falch Madsen
    0

    I've changed to

    <xsl:variable name="startLetter" select="substring(@nodeName,1,1)"/>

    Start Letter=<xsl:value-of select="$startLetter"/><br />

     <xsl:if test="Exslt.ExsltRegularExpressions:match($startLetter, '[a-D]')">

    But the match wont work :/


  • Michael Falch Madsen 70 posts 92 karma points
    Nov 09, 2010 @ 11:59
    Michael Falch Madsen
    0

    This one works

      <xsl:if test="Exslt.ExsltRegularExpressions:test($startLetter, '[A-Sa-s]')">

  • Michael Falch Madsen 70 posts 92 karma points
    Nov 09, 2010 @ 15:26
    Michael Falch Madsen
    0

    One problem more! How do i make the range dynamic?

    I have this:

    <xsl:variable name="startLetter" select="Exslt.ExsltStrings:uppercase(startBogstav)"/>
    <xsl:variable name="endLetter" select="Exslt.ExsltStrings:uppercase(slutBogstav)"/>  

    <xsl:if test="Exslt.ExsltRegularExpressions:test($firstLetter, '[A-Z]')">

     

    And would like to have

    <xsl:if test="Exslt.ExsltRegularExpressions:test($firstLetter, '[$startLetter-$endLetter]')">

    But when i do that i get "[x-y] range in reverse order"

  • Michael Falch Madsen 70 posts 92 karma points
    Nov 16, 2010 @ 13:15
    Michael Falch Madsen
    0

    Got it working with this

    <xsl:variable name="startLetter" select="Exslt.ExsltStrings:uppercase(startBogstav)"/>
          <xsl:variable name="endLetter" select="Exslt.ExsltStrings:uppercase(slutBogstav)"/>   
          <xsl:variable name="reqexp" select="concat('[', $startLetter, '-', $endLetter, ']')"/>

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies