[Home] [By Thread] [By Date] [Recent Entries]
Hello everyone,
Hope somebody can help me with the correct phrasing for this test. It must be within xslt 1.0 In the following xml structure i want to check for a <TableRow> where the child element <Cell> doesn't contain the attribute 'ColSpan'. The reason that i need a <TableRow> without colspan cells is to calculate with an for-each command the number of columns within the table. xml sample: <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]"> <Table> <TableHeader> <TableRow> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">header</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">header</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">header</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">header</Text> </Paragraph> </Cell> </TableRow> </TableHeader> <TableBody> <TableRow> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">veld1</Text> </Paragraph> </Cell> <Cell ColSpan="2" Width="50" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">veld2</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">veld4</Text> </Paragraph> </Cell> </TableRow> <TableRow> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">1</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">2</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">3</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">4</Text> </Paragraph> </Cell> </TableRow> <TableRow> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">i</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">ii</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">iii</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">iv</Text> </Paragraph> </Cell> </TableRow> <TableRow> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">a</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">b</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">c</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">d</Text> </Paragraph> </Cell> </TableRow> </TableBody> <TableFooter> <TableRow> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">footer</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">footer</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">footer</Text> </Paragraph> </Cell> <Cell Width="25" TopBorder="3" RightBorder="3" BottomBorder="3" LeftBorder="3" VAlign="top"> <Paragraph Pstyle="Plattetekst"> <Text Cstyle="[No character style]">footer</Text> </Paragraph> </Cell> </TableRow> </TableFooter> </Table> </Text> </Paragraph> What i got sofar is: <!-- Match 'Table'. --> <xsl:template match="Table"> <informaltable> <xsl:choose> <!-- Check if attribute border (top, right, bottom, left) is defined. --> <!-- Otherwise leave attribute out. --> <xsl:when test="descendant::Cell/@TopBorder"> <xsl:attribute name="border"> <xsl:value-of select="descendant::Cell/ @TopBorder"/> </xsl:attribute> </xsl:when> <xsl:when test="descendant::Cell/@RightBorder"> <xsl:attribute name="border"> <xsl:value-of select="descendant::Cell/ @RightBorder"/> </xsl:attribute> </xsl:when> <xsl:when test="descendant::Cell/@BottomBorder"> <xsl:attribute name="border"> <xsl:value-of select="descendant::Cell/ @BottomBorder"/> </xsl:attribute> </xsl:when> <xsl:when test="descendant::Cell/@LeftBorder"> <xsl:attribute name="border"> <xsl:value-of select="descendant::Cell/ @LeftBorder"/> </xsl:attribute> </xsl:when> </xsl:choose> <xsl:choose> <xsl:when test="descendant::TableRow/ not(Cell[@ColSpan])"> <== this is wrong phrasing i know, but can't find the correct one. <xsl:for-each select="descendant::TableRow/Cell"> <col/> </xsl:for-each> </xsl:when> </xsl:choose> <xsl:apply-templates/>
</informaltable>
</xsl:template>Regards, Casper Voortman
|

Cart



