Subject: finding the correct rows
Posted By: mrame Post Date: 7/23/2008 5:57:19 PM
Hi,
I have table with rows as specified below. The main key is <TL1Position> value and <TL1Commands> value. If two rows contain same <TL1Position> value but any one containing the value for <TL1Commands cmdType = "Create"> as M, then that <TL1Attribute> value should be shown.

<rattrow attrfield = "1">
<rattcell><TL1Instance>0001</TL1Instance></rattcell>
<rattcell><TL1Position>1</TL1Position></rattcell>
<rattcell><TL1Attribute attrType = "Positional">AID</TL1Attribute></rattcell>
<rattcell><TL1Commands cmdType = "Create">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Modify">Mgr</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Delete">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Remove">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Restore">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveIn">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveOut">M</TL1Commands></rattcell>
</rattrow>
<rattrow attrfield = "1">
<rattcell><TL1Instance>0001a</TL1Instance></rattcell>
<rattcell><TL1Position>1</TL1Position></rattcell>
<rattcell><TL1Attribute attrType = "Positional">AID</TL1Attribute></rattcell>
<rattcell><TL1Commands cmdType = "Create">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Modify">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Delete">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Remove">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Restore">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveIn">Ogr</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveOut">N</TL1Commands></rattcell>
</rattrow>
<rattrow attrfield = "1">
<rattcell><TL1Instance>0002</TL1Instance></rattcell>
<rattcell><TL1Position>2</TL1Position></rattcell>
<rattcell><TL1Attribute attrType = "Positional">AID</TL1Attribute></rattcell>
<rattcell><TL1Commands cmdType = "Create">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Modify">Mgr</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Delete">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Remove">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Restore">M</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveIn">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveOut">M</TL1Commands></rattcell>
</rattrow>
<rattrow attrfield = "1">
<rattcell><TL1Instance>0002a</TL1Instance></rattcell>
<rattcell><TL1Position>2</TL1Position></rattcell>
<rattcell><TL1Attribute attrType = "Positional">AID</TL1Attribute></rattcell>
<rattcell><TL1Commands cmdType = "Create">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Modify">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Delete">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Remove">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "Restore">N</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveIn">Ogr</TL1Commands></rattcell>
<rattcell><TL1Commands cmdType = "RetrieveOut">N</TL1Commands></rattcell>
</rattrow>

XSL:

<xsl:template match="rattrow[.//TL1Attribute]" mode="positional">
        <xsl:param name="tl1c"/>
        <xsl:variable name="currRow" select="."/>
    <xsl:variable name="check4">
        <xsl:for-each select="$currRow">
            
            <xsl:choose>
                        <xsl:when test="$tl1c = 'Retrieve'">
                            <xsl:for-each
                                select=".[matches($currRow//TL1Commands[@cmdType='RetrieveIn'], '^[O|Y].*$')]">
                                <xsl:text>[&lt;</xsl:text>
                                <xsl:value-of select=".//TL1Attribute"/>
                                <xsl:text>&gt;]</xsl:text>
                            </xsl:for-each>

                            <xsl:for-each
                                select=".[matches($currRow//TL1Commands[@cmdType='RetrieveIn'], '^M.*$')]">
                                <xsl:text>&lt;</xsl:text>
                                <xsl:value-of select="$currRow//TL1Attribute"/>
                                <xsl:text>&gt;</xsl:text>
                            </xsl:for-each>
                        </xsl:when>

                        <xsl:when test="$tl1c = 'Read'">
                            <xsl:for-each
                                select=".[matches($currRow//TL1Commands[@cmdType='ReadIn'], '^[O|Y].*$')]">
                                <xsl:text>[&lt;</xsl:text>
                                <xsl:value-of select="$currRow//TL1Attribute"/>
                                <xsl:text>&gt;]</xsl:text>
                            </xsl:for-each>

                            <xsl:for-each
                                select=".[matches($currRow//TL1Commands[@cmdType='ReadIn'], '^M.*$')]">
                                <xsl:text>&lt;</xsl:text>
                                <xsl:value-of select="$currRow//TL1Attribute"/>
                                <xsl:text>&gt;</xsl:text>
                            </xsl:for-each>
                        </xsl:when>

                        <xsl:otherwise>
                            <xsl:for-each
                                select=".[matches($currRow//TL1Commands[@cmdType=$tl1c], '^[O|Y].*$')]">
                                <xsl:text>[&lt;</xsl:text>
                                <xsl:value-of select="$currRow//TL1Attribute"/>
                                <xsl:text>&gt;]</xsl:text>
                            </xsl:for-each>

                            <xsl:for-each
                                select=".[matches($currRow//TL1Commands[@cmdType=$tl1c], '^M.*$')]">
                                <xsl:text>&lt;</xsl:text>
                                <xsl:value-of select="$currRow//TL1Attribute"/>
                                <xsl:text>&gt;</xsl:text>
                            </xsl:for-each>
                            <xsl:text>,</xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                  </xsl:for-each>
                  </xsl:variable>
                  <xsl:value-of select="$check4"/>
    </xsl:template>



Go to topic 72921

Return to index page 1