[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Getting a <TableRow> where <Cell> doesn't contain a c

Subject: Getting a <TableRow> where <Cell> doesn't contain a colspan attribute
From: Casper Voortman <casper.voortman@xxxxxxxxxxxx>
Date: Thu, 25 Jun 2009 18:50:27 +0200
 Getting a <TableRow> where <Cell> doesn't contain a  c
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.