tags:

views:

15

answers:

2

How can I handle bullet styles other than numbers in XSLT. I want to draw a table ( XAML flowdocument) and put rows as bellow. hierarchically indented and special marker style. Not using in (XAML)FlowDocument.

1. Some text.........................
    a. Some text.....................
       [1]. Some text................
           a. Some text again........
              [1]. Som text again....

Xml source will be as bellow.

<Root>
    ...
    <Step>
        <Text>First Level</Text>
    </Step>
    <Step>
        <Text>First Level</Text>
        <Step>
            <Text>Second Level</Text>
            <Step>
                <Text>Third Level</Text>
                <Step>
                    <Text>Fourth Level</Text>
                </Step>
            </Step>
        </Step>
    </Step>
    ...
</Root>
A: 

Look at the <xsl:number.../> instruction. It has arguments to format numbers in different styles that cover letters and roman numerals. It's available in both XSLT1 and XSLT2.

Jim Garrison
A: 

Just for fun, this stylesheet:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:inc="include">
 <xsl:output method="text"/>
    <xsl:template match="text()"/>
    <xsl:template match="Step">
        <xsl:variable name="level" select="count(ancestor::Step)"/>
        <xsl:value-of select="substring('&#x9;&#x9;&#x9;&#x9;',1,$level)"/>
        <xsl:number format="{concat(
                             substring('[',
                                       1,
                                       $level and $level mod 2 = 0),
                             substring('1a',
                                       $level mod 2 + 1,
                                       1),
                             substring(']',
                                       1,
                                       $level and $level mod 2 = 0))}. "/>
        <xsl:value-of select="concat(Text,'&#xA;')"/>
        <xsl:apply-templates select="Step"/>
    </xsl:template>
</xsl:stylesheet>

Output:

1. First Level
2. First Level
    a. Second Level
        [1]. Third Level
            a. Fourth Level
Alejandro