[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: adding hierarchy

Subject: Re: adding hierarchy
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 11 Mar 2008 16:38:02 -0400
Re:  adding hierarchy
Jim,

This is doable, but it'd be much easier if you made all your ListItem elements into simple 'item' elements first, flagging their levels as (say) @level attributes. Is that a possibility, either by fixing it at the source, or running a near-identity transform to make it so?

Also, you didn't say whether XSLT 2.0 is an option for you. Hope so: XSLT 2.0 offers much more elegant (and fun) solutions to this.

Cheers,
Wendell

At 04:14 PM 3/11/2008, you wrote:
I want to wrap all ListItem1, ListItem2, ListItem3 elements in appropriate
<list></list> to show the level of the lists.
So when finished, I can count the number of ancestor::list to determine
the level of the items.
I've tried using samples in the FAQ but I only get part way. Time to ask
for help.

starting with

<?xml version="1.0" encoding="UTF-8"?>
<scripture>
    <div type="book" osisID="Matthew">
        <div type="section" scope="Mat.1.1-Mat.1.17">
            <title>
                <seg>Makholo a dzinza ya Yezu Kirixtu.</seg>
            </title>
            <p>
                <milestone osisID="Mat.1" n="1"/>
                <milestone osisID="Mat.1.1" n="1"/>
                <seg>Yezu Kirixtu abaliwa ku mimba ya Dhavidhi, dzinza ya
baba Abharamu.</seg>
            </p>
            <ListItem1>
                <milestone osisID="Mat.1.2" n="2"/>
                <seg>Abharamu abala Izaki;</seg>
            </ListItem1>
            <ListItem2>
                <seg>Izaki abala Djakobu;</seg>
            </ListItem2>
            <ListItem3>
                <seg>This isn't in the document but it would be allowed
</seg>
            </ListItem3>
            <ListItem3>
                <seg>more allowed</seg>
            </ListItem3>
            <ListItem2>
                <seg>Djakobu abala Djuda na abale ace.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.3" n="3"/>
                <seg>Djuda na nkazi wace Tamari abala Faresi na Zara;
</seg>
            </ListItem2>
            <ListItem2>
                <seg>Faresi abala Esiromu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Esiromu abala Aramu.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.4" n="4"/>
                <seg>Aramu abala Aminadabu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Aminadabu abala Nasoni;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Nasoni abala Salamoni.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.5" n="5"/>
                <seg>Salamoni na nkazi wace Rakabi abala Bozi;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Bozi na nkazi wace Ruti abala Obedi;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Obedi abala Djesi;</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.6" n="6"/>
                <seg>Djesi abala mambo Dhavidhi;</seg>
            </ListItem2>
            <ListItem1>
                <seg>Dhavidhi abala Salomoni na nkazi akhali wa Uriya;
</seg>
            </ListItem1>
            <ListItem2>
                <milestone osisID="Mat.1.7" n="7"/>
                <seg>Salomoni abala Reboamu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Reboamu abala Abiya;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Abiya abala Asa.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.8" n="8"/>
                <seg>Asa Abala Djozafati;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Djozafati abala Djoramu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Djoramu abala Uziya.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.9" n="9"/>
                <seg>Uziya abala Djotamu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Djotamu abala Akasi;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Akasi abala Ezekiya.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.10" n="10"/>
                <seg>Ezekiya abala Manasi;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Manasi abala Amoni;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Amoni abala Djosiya.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.11" n="11"/>
                <seg>Djosiya abala Djekoniya na abale ace, pa midzidzi
ikhadatapatwa mbumba ya
                    madjudeu kwenda ku dziko ya Babilonya.</seg>
            </ListItem2>
            <ListItem1>
                <milestone osisID="Mat.1.12" n="12"/>
            </ListItem1>
            <ListItem2>
                <seg>Djekoniya abala Salatiyeri;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Salatiyeri abala Zolobabeli.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.13" n="13"/>
                <seg>Zolobabeli abala Abiyudi;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Abiyudi abala Eliakimu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Eliakimu abala Azori.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.14" n="14"/>
                <seg>Azori abala Sadoki;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Sadoki abala Akimu;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Akimu abala Eliyudi.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.15" n="15"/>
                <seg>Eliyudi abala Elizari;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Elizari abala Matani;</seg>
            </ListItem2>
            <ListItem2>
                <seg>Matani abala Djakobu.</seg>
            </ListItem2>
            <ListItem2>
                <milestone osisID="Mat.1.16" n="16"/>
                <seg>Djakobu abala Zuze, mamuna ace Mariya na baba wa Yezu
wa kunfuya; abala Yezu,
                    anadziwika dzina ya Kirixtu.</seg>
            </ListItem2>
            <p>
                <milestone osisID="Mat.1.17" n="17"/>
                <seg>Na tenepa, asagumanika makholo khumi na manai a
dzinza ya madjudeu, tomera kuna
                    Abharamu mpaka kuna Dhavidhi; tomera kuna Dhavidhi
mpaka kubuluka kwawo pa
                    kutapatwa ku Babilonya, kusagumanika khumi na manai a
makholo; na kubulukira ku
                    Babilonya mpaka kufikira pa kubalwa kwa Misiya,
kusagumanika pontho makholo
                    khumi na manai.</seg>
            </p>
        </div>
    </div>
</scripture>

desired output with <list></list> added
I identified these with <!-- added -->
You do not need to add the comment.

<?xml version="1.0" encoding="UTF-8"?>
<scripture>
    <div type="book" osisID="Matthew">
        <div type="section" scope="Mat.1.1-Mat.1.17">
            <title>
                <seg>Makholo a dzinza ya Yezu Kirixtu.</seg>
            </title>
            <p>
                <milestone osisID="Mat.1" n="1"/>
                <milestone osisID="Mat.1.1" n="1"/>
                <seg>Yezu Kirixtu abaliwa ku mimba ya Dhavidhi, dzinza ya
baba Abharamu.</seg>
            </p>
            <list><!-- added -->
                <ListItem1>
                    <milestone osisID="Mat.1.2" n="2"/>
                    <seg>Abharamu abala Izaki;</seg>
                </ListItem1>
                <list><!-- added -->
                    <ListItem2>
                        <seg>Izaki abala Djakobu;</seg>
                    </ListItem2>
                    <list><!-- added -->
                        <ListItem3>
                            <seg>This isn't in the document but it would
be allowed</seg>
                        </ListItem3>
                        <ListItem3>
                            <seg>more allowed</seg>
                        </ListItem3>
                    </list><!-- added -->
                    <ListItem2>
                        <seg>Djakobu abala Djuda na abale ace.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.3" n="3"/>
                        <seg>Djuda na nkazi wace Tamari abala Faresi na
Zara;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Faresi abala Esiromu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Esiromu abala Aramu.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.4" n="4"/>
                        <seg>Aramu abala Aminadabu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Aminadabu abala Nasoni;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Nasoni abala Salamoni.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.5" n="5"/>
                        <seg>Salamoni na nkazi wace Rakabi abala Bozi;
</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Bozi na nkazi wace Ruti abala Obedi;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Obedi abala Djesi;</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.6" n="6"/>
                        <seg>Djesi abala mambo Dhavidhi;</seg>
                    </ListItem2>
                </list><!-- added -->
                <ListItem1>
                    <seg>Dhavidhi abala Salomoni na nkazi akhali wa Uriya;
</seg>
                </ListItem1>
                <list><!-- added -->
                    <ListItem2>
                        <milestone osisID="Mat.1.7" n="7"/>
                        <seg>Salomoni abala Reboamu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Reboamu abala Abiya;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Abiya abala Asa.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.8" n="8"/>
                        <seg>Asa Abala Djozafati;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Djozafati abala Djoramu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Djoramu abala Uziya.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.9" n="9"/>
                        <seg>Uziya abala Djotamu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Djotamu abala Akasi;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Akasi abala Ezekiya.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.10" n="10"/>
                        <seg>Ezekiya abala Manasi;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Manasi abala Amoni;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Amoni abala Djosiya.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.11" n="11"/>
                        <seg>Djosiya abala Djekoniya na abale ace, pa
midzidzi ikhadatapatwa mbumba
                            ya madjudeu kwenda ku dziko ya Babilonya.
</seg>
                    </ListItem2>
                </list><!-- added -->
                <ListItem1>
                    <milestone osisID="Mat.1.12" n="12"/>
                </ListItem1>
                <list><!-- added -->
                    <ListItem2>
                        <seg>Djekoniya abala Salatiyeri;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Salatiyeri abala Zolobabeli.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.13" n="13"/>
                        <seg>Zolobabeli abala Abiyudi;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Abiyudi abala Eliakimu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Eliakimu abala Azori.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.14" n="14"/>
                        <seg>Azori abala Sadoki;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Sadoki abala Akimu;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Akimu abala Eliyudi.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.15" n="15"/>
                        <seg>Eliyudi abala Elizari;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Elizari abala Matani;</seg>
                    </ListItem2>
                    <ListItem2>
                        <seg>Matani abala Djakobu.</seg>
                    </ListItem2>
                    <ListItem2>
                        <milestone osisID="Mat.1.16" n="16"/>
                        <seg>Djakobu abala Zuze, mamuna ace Mariya na baba
wa Yezu wa kunfuya; abala
                            Yezu, anadziwika dzina ya Kirixtu.</seg>
                    </ListItem2>
                </list><!-- added -->
            </list><!-- added -->
            <p>
                <milestone osisID="Mat.1.17" n="17"/>
                <seg>Na tenepa, asagumanika makholo khumi na manai a
dzinza ya madjudeu, tomera kuna
                    Abharamu mpaka kuna Dhavidhi; tomera kuna Dhavidhi
mpaka kubuluka kwawo pa
                    kutapatwa ku Babilonya, kusagumanika khumi na manai a
makholo; na kubulukira ku
                    Babilonya mpaka kufikira pa kubalwa kwa Misiya,
kusagumanika pontho makholo
                    khumi na manai.</seg>
            </p>
        </div>
    </div>
</scripture>


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.