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 August 1st, 2005, 12:20 PM
Authorized User
 
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default KEY QUESTION

In my xslt I am having to use this statement to go back up the tree so that I can compare the @id attribute of the Variable node with the one from the current GroupVar node at the bottom of my xml tree.

../../../../../Project/Variables/Variable[@id=$varID]/@title

I have seen on page 499 of XSLT 2nd Edition Prog Ref that I could use a key to find nodes and it would also speed the process. I would appreciate if someone could give me some help about creating the key and using it.

I am not sure if I have to create the key using the GroupVar node like that:

<xsl:key name="idEquality" match"GroupVar" use="@varid"/>

or using the Variable node like that:

<xsl:key name="idEquality" match"Variable" use="@id"/>

Also, I am not sure how to use the key after it is created. What is happening when we create this key?? I am using xslt 1.0 (MSXML)

This is the xslt I am currently using:

<xsl:template match="Cluster">
        <TABLE cellSpacing="0" cellPadding="0" width="100%" border="0" bordercolor="green" ID="Table2">
            <tbody>
                <TR>
                    <TD class="clsSideBarBlockRondText">
                        <DIV align="center">
                            <table ID="Table1">
                                <xsl:for-each select="Solutions/Solution/Groups/Group">
                                    <xsl:variable name="perc" select="round((@sample div //Filter/@sample)*100)"/>

                                    <tr>
                                            <td class="bottom"><img src="../imagestest/greenblock.gif" height="12px" width="{$perc}" align="absmiddle"/></td>
                                            <td nowrap="true" class="gridText"><xsl:value-of select="$perc"/>% (<xsl:value-of select="@sample"/>)</td>
                                    </tr>

                                    <tr>
                                            <td class="bottom" colspan="2"><div class="yBackground">Group <xsl:value-of select="position()"/></div></td> </tr>

                                    <xsl:for-each select="GroupVar">
                                        <xsl:variable name="varID" select="@varid"/>

                                        <tr>
                                            <td class="bottom"><div class="textRed"><xsl:value-of select="../../../../../Project/Variables/Variable[@id=$varID]/@title"/></div></td>
                                            <td class="bottom" nowrap="true"><div class="textRed"><xsl:value-of select="@stddevmean"/></div></td>
                                        </tr>

                                    </xsl:for-each>
                                </xsl:for-each>
                            </table>
                        </DIV>
                    </TD>
                </TR>
            </tbody>
        </TABLE>
    </xsl:template>


This is the XML

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="Summary.xslt"?>
<Cluster>
    <Project name="test3" title="">
        <Survey name="gb02spp" title="GB TGI 2002 Spring (January 2001-December 2001) - pop"/>
        <Filter sample="25131" wgtd="46818.9874" expr="dbsexlad" title="All Adults"/>
        <Options algotype="0" algotitle="Multi K-Means" minsoltn="2" maxsoltn="2" normalised="1" missingvalues="0" stoptest="0"/>
        <Variables>
            <Variable id="LMTAA" title="On television I enjoy the adverts as much as the programmes" midpoint="3.00" type="2" mean="2.4848" sd="1.2151">
                <Values>
                    <Value title="Definitely Agree" expr="LMTAADAG" sample="1523" wgtd="2555.0900" midpoint="5.00"/>
                    <Value title="Tend To Agree" expr="LMTAATTA" sample="3719" wgtd="6942.2500" midpoint="4.00"/>
                    <Value title="Neither Agree Nor Disagree" expr="LMTAANAN" sample="4679" wgtd="8685.1300" midpoint="3.00"/>
                    <Value title="Tend To Disagree" expr="LMTAATTD" sample="5460" wgtd="10507.8200" midpoint="2.00"/>
                    <Value title="Definitely Disagree" expr="LMTAADDI" sample="7126" wgtd="13742.1600" midpoint="1.00"/>
                    <Value title="Not Applicable" expr="LMTAANAP" sample="544" wgtd="949.6000" midpoint="3.00"/>
                    <Value title="Not Stated" expr="LMTAANNS" sample="2080" wgtd="3436.9300" midpoint="3.00"/>
                </Values>
            </Variable>
            <Variable id="LMPWA" title="A Lot Of Advertising Patronises Women" midpoint="3.00" type="2" mean="3.2587" sd="0.9939">
                <Values>
                    <Value title="Definitely Agree" expr="LMPWADAG" sample="3035" wgtd="5270.1800" midpoint="5.00"/>
                    <Value title="Tend To Agree" expr="LMPWATTA" sample="6007" wgtd="10886.6400" midpoint="4.00"/>
                    <Value title="Neither Agree Nor Disagree" expr="LMPWANAN" sample="8102" wgtd="15808.9800" midpoint="3.00"/>
                    <Value title="Tend To Disagree" expr="LMPWATTD" sample="2789" wgtd="5637.5100" midpoint="2.00"/>
                    <Value title="Definitely Disagree" expr="LMPWADDI" sample="1393" wgtd="2759.9400" midpoint="1.00"/>
                    <Value title="Not Applicable" expr="LMPWANAP" sample="1440" wgtd="2525.4400" midpoint="3.00"/>
                    <Value title="Not Stated" expr="LMPWANNS" sample="2365" wgtd="3930.3000" midpoint="3.00"/>
                </Values>
            </Variable>
            <Variable id="LMGCA" title="I often go in for competitions in newspapers and magazines" midpoint="3.00" type="2" mean="2.5081" sd="1.1628">
                <Values>
                    <Value title="Definitely Agree" expr="LMGCADAG" sample="1416" wgtd="2276.1800" midpoint="5.00"/>
                    <Value title="Tend To Agree" expr="LMGCATTA" sample="2922" wgtd="5092.8000" midpoint="4.00"/>
                    <Value title="Neither Agree Nor Disagree" expr="LMGCANAN" sample="3562" wgtd="6765.4200" midpoint="3.00"/>
                    <Value title="Tend To Disagree" expr="LMGCATTD" sample="4756" wgtd="9342.2800" midpoint="2.00"/>
                    <Value title="Definitely Disagree" expr="LMGCADDI" sample="6680" wgtd="13368.0400" midpoint="1.00"/>
                    <Value title="Not Applicable" expr="LMGCANAP" sample="3550" wgtd="6156.7200" midpoint="3.00"/>
                    <Value title="Not Stated" expr="LMGCANNS" sample="2245" wgtd="3817.5500" midpoint="3.00"/>
                </Values>
            </Variable>
            <Variable id="LMAEA" title="I Expect Advertising To Be Entertaining" midpoint="3.00" type="2" mean="3.3699" sd="0.9824">
                <Values>
                    <Value title="Definitely Agree" expr="LMAEADAG" sample="3078" wgtd="5817.8700" midpoint="5.00"/>
                    <Value title="Tend To Agree" expr="LMAEATTA" sample="7848" wgtd="15121.4000" midpoint="4.00"/>
                    <Value title="Neither Agree Nor Disagree" expr="LMAEANAN" sample="7513" wgtd="14068.7100" midpoint="3.00"/>
                    <Value title="Tend To Disagree" expr="LMAEATTD" sample="1886" wgtd="3599.6600" midpoint="2.00"/>
                    <Value title="Definitely Disagree" expr="LMAEADDI" sample="1411" wgtd="2556.8200" midpoint="1.00"/>
                    <Value title="Not Applicable" expr="LMAEANAP" sample="1054" wgtd="1710.7800" midpoint="3.00"/>
                    <Value title="Not Stated" expr="LMAEANNS" sample="2341" wgtd="3943.7600" midpoint="3.00"/>
                </Values>
            </Variable>
        </Variables>
    </Project>
    <Solutions variance="100520.0000">
        <Solution ngroups="2" variance="79966.4596" varexp="20.4472">
            <Groups>
                <Group id="1" sample="13098" variance="39988.7861">
                    <GroupVar varid="LMTAA" mean="3.3365" absdevmean="0.8517" stddevmean="0.7009" variance=""/>
                    <GroupVar varid="LMPWA" mean="3.2585" absdevmean="-0.0002" stddevmean="-0.0002" variance=""/>
                    <GroupVar varid="LMGCA" mean="3.0231" absdevmean="0.5150" stddevmean="0.4429" variance=""/>
                    <GroupVar varid="LMAEA" mean="3.6182" absdevmean="0.2483" stddevmean="0.2527" variance=""/>
                </Group>
                <Group id="2" sample="12033" variance="39977.6735">
                    <GroupVar varid="LMTAA" mean="1.5577" absdevmean="-0.9271" stddevmean="-0.7630" variance=""/>
                    <GroupVar varid="LMPWA" mean="3.2590" absdevmean="0.0002" stddevmean="0.0002" variance=""/>
                    <GroupVar varid="LMGCA" mean="1.9475" absdevmean="-0.5606" stddevmean="-0.4821" variance=""/>
                    <GroupVar varid="LMAEA" mean="3.0996" absdevmean="-0.2703" stddevmean="-0.2751" variance=""/>
                </Group>
            </Groups>
        </Solution>
    </Solutions>

</Cluster>


Cheers,

Cleyton


 
Old August 2nd, 2005, 04:52 PM
Authorized User
 
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry,

Is thre anything wrong with my question?? I have received no replies at all?

Cheers,

Cleyton

 
Old August 2nd, 2005, 06:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, your question is too long. Simplify it, distill the essence of your problem, and you might even solve it yourself.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
<bean:message key="PNR.INPUT"/> key has null value warsha_14 Struts 1 November 13th, 2006 07:26 AM
question about distictrow KEY word bbqlee Access 1 August 29th, 2006 10:54 AM
TAB KEY working together KEY PRESS event thomaz C# 4 August 20th, 2006 02:47 PM
Composite key question hlchuah77 SQL Server 2000 3 October 19th, 2004 05:24 AM
FOREIGN KEY and PRIMARY KEY Constraints junemo Oracle 10 June 15th, 2004 01:00 AM





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