Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2016, 09:07 AM
Registered User
 
Join Date: Jul 2016
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default translate numeric to alphanumeric

Hello everyone,

I need to add alphanumeric values to a list based on their position.
Is there an easy way to do this with xslt 1.0?

Input:
<list>
<li>
<p>text</p>
</li>
<li>
<p>text</p>
</li>
</list>

output
<list>
<li>
<nr>a</nr>
<p>text</p>
</li>
<li>
<nr>b</nr>
<p>text</p>
</li>
</list>
 
Old November 6th, 2016, 09:15 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Use xsl: number format="a", see http://xsltransform.net/bwdwrZ,
Code:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="li">
        <xsl:copy>
            <nr>
                <xsl:number format="a"/>
            </nr>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
</xsl:transform>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if the password contains non-alphanumeric character dotnet_user C# 2008 aka C# 3.0 2 April 12th, 2010 09:37 PM
Gridview alphanumeric paging help javivilchis ASP.NET 2.0 Professional 13 August 26th, 2009 10:41 AM
From numeric to alfa numeric ebekir XSLT 1 August 10th, 2007 06:13 AM
Regex and Alphanumeric matching? quantass BOOK: Beginning Regular Expressions 0 March 10th, 2007 11:34 AM
Javascript for an alphanumeric calculator gilgalbiblewheel Java GUI 0 September 13th, 2004 11:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.