Copied to clipboard

Flag this post as spam?

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


  • Michiel 2 posts 22 karma points
    Sep 17, 2010 @ 15:33
    Michiel
    0

    How to create capitals with EXSLT

    Hi,

    I am trying to put the first letter of a menu item in capital. Right now alle the characters are lowercase. But I can't find out how to do this.

    I think it's in this line;

     <h2><xsl:value-of select="Exslt.ExsltStrings:lowercase($level2Page/menuTitle)"/></h2>

    Changing "lowercase" into "uppercase" makes all the characters capitalized. I just want the first letter to be capitalized. Is this possible and more important, how is this possible.

    The entire code is;

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <xsl:variable name="level2Page" select="$currentPage/ancestor-or-self::* [@level=2]"/>
      <h2><xsl:value-of select="Exslt.ExsltStrings:lowercase($level2Page/menuTitle)"/></h2>
      <xsl:if test="count($level2Page/* [@isDoc and string(umbracoNaviHide) != '1'])">
        <ul>
          <xsl:for-each select="$level2Page/* [@isDoc and string(umbracoNaviHide) != '1']">
           
            <li>
                <!-- check voor actief submenu -->
                <xsl:if test="./@id = $currentPage/@id">
                  <xsl:attribute name="class">active</xsl:attribute>
                </xsl:if>
             
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="./menuTitle"/>
              </a>

            </li>
           
              <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">
               
                <li>
                    <!-- check voor actief submenu -->
                  <xsl:attribute name="class">
                    <xsl:text>submenu</xsl:text>
                    <xsl:if test="./@id = $currentPage/@id">
                       <xsl:text> active</xsl:text>
                    </xsl:if>
                  </xsl:attribute>
                 
                  <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="./menuTitle"/>
                  </a>
                </li>
               
              </xsl:for-each>
          </xsl:for-each>
        </ul>
      </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

     

    Thanks!

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Sep 17, 2010 @ 15:40
    Chriztian Steinmeier
    2

    Hi Michiel,

    Have you tried to just output the plain value to the tag and then capitalize it with CSS?

    XSLT:

    <h2><xsl:value-of select="$level2Page/menuTitle" /></h2>

    CSS:

    h2 { text-transform: capitalize; }

     

    /Chriztian

     

  • Michiel 2 posts 22 karma points
    Sep 17, 2010 @ 15:54
    Michiel
    0

    Sometimes things are just to easy.

    Thanks!!

  • sharon Schmidt 12 posts 32 karma points
    Dec 08, 2010 @ 14:50
    sharon Schmidt
    0

    Tried using this method for an umbraco field and it isn't working.

    <title id="BrowserPageTitle">Honey Baked Ham<umbraco:Item  field="pageTitle" insertTextBefore=" - " case="lower" runat="server"></umbraco:Item></title>

    The data is purposely stored in UPPERCASE , so I thought I would lower it first. and then apply the style.  I also tried removing the field case attribute, but it didn't work either.

    When you insert it gives you a choice of none, lower or upper only.

    Have any suggestions?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 19, 2010 @ 12:39
    Jan Skovgaard
    0

    Hi Sharon

    Maybe you'll need to create an XSLT macro to be able to return the text in lowercase then. In the Exslt extensions there is a lowercase() method, which you should be able to use. Once this is done you should be able to capitalize it.

    Hope this helps.

    /Jan

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 19, 2010 @ 23:32
    Lee Kelleher
    1

    Sharon,

    If you are interested in an XSLT extension to do this, try the following:

    public static string ToTitleCase(string input)
    {
        return System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(input);
    }
    
    We're going to be adding this to the next version of uComponents (probably v2.1 in a few weeks).

    Cheers, Lee.

  • sharon Schmidt 12 posts 32 karma points
    Dec 20, 2010 @ 20:51
    sharon Schmidt
    0

    Thanks for the info.  I am new to xslt umbraco and xslt extensions.  With your help and all the other how to's on the forums.  I got it working!

Please Sign in or register to post replies

Write your reply to:

Draft