Article

emarinus's picture

XSLT policy to convert attributes into proper case format

Author Info

6 August 2008 - 12:26am
Submitted by: emarinus

article
Reads:

2865

Score:
4
4
3
 
Comments:

0

The attached XSLT Policy can be modified to handle specific attributes and for each attribute can be specified if it should be lower-, upper-, or titlecase (each first letter of each word uppercase) format.

The policy contains 2 important variables:

  1. attr-config
    Attr-config acts as an XML array and contains all attributes that need to be converted together with the format they need to be converted into.

    <xsl:variable name="attr_config">
               <attr name="STATUS">title</attr>
               <attr name="ACHTERNAAM">title</attr>
               <attr name="VOORLETTERS">upper</attr>
               <attr name="TUSSENVOEGSELS">title</attr>
               <attr name="ROEPNAAM">title</attr>
               <attr name="VOORNAMEN">title</attr>
               <attr name="GESLACHT">upper</attr>
               <attr name="EMAIL_ADRES">lower</attr>
               <attr name="CODE_LAND">upper</attr>
               <attr name="NAAM_LAND">title</attr>
               <attr name="STRAAT">title</attr>
               <attr name="POSTCODE">upper</attr>
               <attr name="PLAATS">title</attr>
    </xsl:variable>
    
    

    In the above example the STATUS attribute is converted into title-case, the ACHTERNAAM attribute into upper-case and so on. Just add more attribute – value pairs into the list to extend the number of attributes (or delete attributes if you like).

  2. capitalafter
    The capitalafter variable contains characters after which a capital is converted. In most cases it contains just a whitespace character, but in some countries words like ‘Hendrik-Ido-Ambacht’ (which is a Dutch city) or names like ‘Mary-Jose’ must be converted properly to. For these exceptions you can adjust the capitalafter variable.

    <xsl:variable name="capitalafter"> -.</xsl:variable>
    
    

The rest is done for you.

AttachmentSize
Convert case_final.xsl_.zip1.87 KB

Author Info

6 August 2008 - 12:26am
Submitted by: emarinus




User Comments

© 2009 Novell, Inc. All Rights Reserved.