Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL - 3 column table, fill 2 cells depending on type or fill all 3

Status
Not open for further replies.

dseaver

IS-IT--Management
Jul 13, 2006
467
I have a table where either 2 or 3 columns are going to be filled, but there are 2 types of nodes filling them. The first two columns are the first type (A) and the third column is the second type(A). The input into the row is either 2A, 1A 1B, or 2A 1B. I want B in the third column regardless. The first cell in the Table will always be populated. I have conditional labeling of the cells right now.

Here is the XSL so far for the cells
Code:
<xsl:for-each select="Child">
				<fo:table-cell border="1pt solid black">
					<xsl:if test="string(TypeA/@Number)">
						<fo:block> <xsl:value-of select="Name"/></fo:block>
						<fo:block><xsl:value-of select="TypeA/@Number"/></fo:block>

					</xsl:if>
					<xsl:if test="string(TypeB/@Number)">
						<fo:block> <xsl:value-of select="Name"/></fo:block>
						<fo:block><xsl:value-of select="TypeB/@Number"/></fo:block>
						
					</xsl:if>
				</fo:table-cell>
			</xsl:for-each>

And here is the XML structure
Code:
 <Parent>
- <Child>
  <Name>Cell A</Name> 
  <TypeA Number="6" /> 
  </Child>
- <Child>
  <Name>Cell B</Name> 
  <TypeA Number="4" /> 
  </Child>
  </Parent>
- <Parent>
- <Child>
  <Name>Cell C</Name> 
  <TypeA Number="9" /> 
  </Child>
- <Child>
  <Name>Cell D</Name> 
  <TypeB Number="4" /> 
  </Child>
  </Parent>

THe output would be
Code:
|Column 1|Column 2| Column3|
|Cell A  |Cell B  |        |
|Cell C  |        |Cell D  |

Thanks!
 
I figured the that part out by changing the code so that the cell tags were within the if statement and defined the cell for type be as <fo:table-cell column-number="3">. Is there a way to add the cell borders to each cell, even if it isnt populated? I have column borders, but cant get any row borders
 
How come this does not work?
Code:
<fo:table-row border-width="1pt" border-style="solid">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top