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 15th, 2004, 07:02 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's fantastic, thanks a lot guys.

The only minor things I need to resolve now are how to cater for score’s that are the same. So if 2 players have the same time then they should get the same medal. I couldn't see a way to use sort to resolve this so will I'll have to check each score manually?

The other issue is that I've changed the xml to have 2 score tags per player for some events but not all <record-score-a> and <record-score-b>.
Which lead me to create a record-tag variable but I was having trouble passing this between templates as it's value get's cleared.

Example below:
.
.
.
    <xsl:template match="records">
        <xsl:variable name="tag-name">
            <xsl:choose>
                <xsl:when test="@type = 'Type2'">record-score</xsl:when>
                <xsl:when test="@type = 'Type3'">record-mixed</xsl:when>
                <xsl:otherwise>recordAB</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:apply-templates select="events/event">
             <xsl:with-param name="record-tag">$tag-name</xsl:with-param>

        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="events/event">
        <xsl:param name="record-tag"/>

        <xsl:choose>
             <xsl:when test="$record-tag = 'recordAB'">
                 <xsl:apply-templates select="player">
                    <xsl:sort data-type="number" order="{$sortDirection}" select="record-score-a"/>
                </xsl:apply-templates>
                <xsl:apply-templates select="player">
                    <xsl:sort data-type="number" order="{$sortDirection}" select="record-score-b"/>
                </xsl:apply-templates>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates select="player">
                    <xsl:sort data-type="number" order="{$sortDirection}" select="$record-tag"/>
                </xsl:apply-templates>
            </xsl:otherwise>
        </xsl:choose>
.
.
.

Any further help would be much appreciated.
Ally

 
Old November 15th, 2004, 07:06 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you show the revised XML? What criteria do you use to decide wheteher to use record-score-a or record-score-b?



--

Joe (Microsoft MVP - XML)
 
Old November 15th, 2004, 07:26 AM
Registered User
 
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Adding the 2 score tags now means there are 2 medals for each event. So Player 1 would get 2 golds for event 1 and 2 golds for event 2.

Here is an example of the updated xml.

<games xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <records type="Type1">
        <events>
            <event name="event1" score="time">
                <player name="Player1">
                    <record-score-a>10.00</record-score-a>
                    <record-score-b>20.00</record-score-b>
                </player>
                <player name="Player2">
                    <record-score-a>11.00</record-score-a>
                    <record-score-b>22.00</record-score-b>
                </player>
                <player name="Player3">
                    <record-score-a>12.00</record-score-a>
                    <record-score-b>24.00</record-score-b>
                </player>
            </event>
            <event name="event2" score="time">
                <player name="Player1">
                    <record-score-a>10.00</record-score-a>
                    <record-score-b>20.00</record-score-b>
                </player>
                <player name="Player2">
                    <record-score-a>15.00</record-score-a>
                    <record-score-b>30.00</record-score-b>
                </player>
                <player name="Player3">
                    <record-score-a>20.00</record-score-a>
                    <record-score-b>40.00</record-score-b>
                </player>
            </event>
        </events>
    </records>
    <records type="Type2">
        <events>
            <event name="event3" score="points">
                <player name="Player1">
                    <record-score>200</record-score>
                </player>
                <player name="Player2">
                    <record-score>100</record-score>
                </player>
                <player name="Player3">
                    <record-score>50</record-score>
                </player>
            </event>
            <event name="event4" score="points">
                <player name="Player1">
                    <record-score>10</record-score>
                </player>
                <player name="Player2">
                    <record-score>20</record-score>
                </player>
                <player name="Player3">
                    <record-score>5</record-score>
                </player>
            </event>
        </events>
    </records>
</games>

Ally






Similar Threads
Thread Thread Starter Forum Replies Last Post
creating table ph0neman Classic ASP Basics 3 January 22nd, 2008 05:06 PM
Ch. 4 -1. Creating a Table jfr BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 February 16th, 2005 02:26 PM
creating a table on server2 FALCONSEYE SQL Server 2000 3 January 26th, 2005 03:16 PM
Creating table with existing table without value kumar_kumar Oracle 1 January 4th, 2005 07:12 AM





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