Subject: [xsl] compare a cell of a matrix with all other From: "Markus Hanel" <markus.hanel@xxxxxx> Date: Mon, 24 Nov 2003 10:56:36 +0100 (MET) |
Hello, I need some help. I have a matrix of a optional number of columns and rows. The question in this example has two answers. The first answer is the solution in the first cell, and the second answer is the solution in the second cell of a row. The student can write the answer in a optional row. I had to compare the first solution "Vorarlberg" with the valid_input of the first cell in the first row, the second row, and so on. At this example "Vorarlberg" is right at the second row: Now i had to compare the second answer "Bregenz" in the second cell of the actual row. Is the first answer right i had to sum the points of the first solution, is the second answer right I had to do the same. My xsl does not really work, the xml structure follows. <xsl:template match="MultipleAnswer" mode="table"> <xsl:for-each select="table/row"> <xsl:call-template name="sum_m" /> </xsl:for-each> </xsl:template> <xsl:template name="sum_m"> <xsl:param name="i" select="1" /> <xsl:param name="last" select="count(child::*)" /> <xsl:param name="sum" select="0" /> <xsl:variable name="answer" select="cell[$i]/solution" /> <xsl:choose> <xsl:when test="$i < $last + 1"> <xsl:variable name="total"> <xsl:for-each select="../row"> <xsl:choose> <xsl:when test="contains(cell[$i]/solution/@valid_input, $answer)"> <xsl:value-of select="cell[$i]/solution/@points" /> </xsl:when> <xsl:otherwise> 0 </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:variable> <xsl:call-template name="sum_m"> <xsl:with-param name="i" select="$i + 1" /> <xsl:with-param name="sum" select="$sum + $total" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <td style="width:20px"><xsl:value-of select="$sum" /></td> </xsl:otherwise> </xsl:choose> </xsl:template> <MultipleAnswer> <notice>Die Reihenfolge der Eingabe spielt keine Rolle!</notice> <question>Nenne alle Österreichischen Bundesländer und deren Hauptstädte!</question> <table> <column>Bundesland</column> <column>Hauptstadt</column> <row number="1"> <cell> <solution type="text" points="0" valid_input="Tirol">Vorarlberg</solution> </cell> <cell> <solution type="text" points="1" valid_input="Innsbruck">Bregenz</solution> </cell> </row> <row number="2"> <cell> <solution type="text" points="2" valid_input="Vorarlberg">Tirol</solution> </cell> <cell> <solution type="text" points="3" valid_input="Bregenz">Innsbruck</solution> </cell> </row> <row number="3"> <cell> <solution type="text" points="4" valid_input="Salzburg">Salzburg</solution> </cell> <cell> <solution type="text" points="5" valid_input="Salzburg">Salzburg</solution> </cell> </row> <row number="4"> <cell> <solution type="text" points="6" valid_input="Oberösterreich"></solution> </cell> <cell> <solution type="text" points="7" valid_input="Linz"></solution> </cell> </row> <row number="5"> <cell> <solution type="text" points="8" valid_input="Niederösterreich"></solution> </cell> <cell> <solution type="text" points="9" valid_input="Sankt Pölten"></solution> </cell> </row> <row number="6"> <cell> <solution type="text" points="10" valid_input="Wien"></solution> </cell> <cell> <solution type="text" points="11" valid_input="Wien"></solution> </cell> </row> <row number="7"> <cell> <solution type="text" points="12" valid_input="Burgenland"></solution> </cell> <cell> <solution type="text" points="13" valid_input="Eisenstadt"></solution> </cell> </row> <row number="8"> <cell> <solution type="text" points="14" valid_input="Steiermark"></solution> </cell> <cell> <solution type="text" points="15" valid_input="Graz"></solution> </cell> </row> <row number="9"> <cell> <solution type="text" points="16" valid_input="Kärnten"></solution> </cell> <cell> <solution type="text" points="17" valid_input="Klagenfurt"></solution> </cell> </row> </table> </MultipleAnswer> -- NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien... Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService Jetzt kostenlos anmelden unter http://www.gmx.net +++ GMX - die erste Adresse für Mail, Message, More! +++ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sibling in the Pattern(ma, David Carlisle | Thread | [xsl] Open file, Ricardo Saraiva |
Re: [xsl] Sibling in the Pattern(ma, David Carlisle | Date | Re: [xsl] XML generation from a tex, David Carlisle |
Month |