Table with 2 columns
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Mon Jan 05, 2009 11:08 pm
Table with 2 columns
Hi,
I am quite new to XSL and have maybe a simple problem, but i am not sure what the best solution might be.
imagine a xml file:
<root>
<number> 1 </number>
<number> 2 </number>
<number> 3 </number>
<number> 4 </number>
<number> 5 </number>
</root>
I would like to put this numbers into a table with 2 columns.
imagine a table:
column1--column2
1------------------ 2
3------------------ 4
5---------
The point is, that i do not know how many numbers/table-cells there are. There might be 5 or 99.
So, is it possible to count the <number> nodes and automaticly put the 1. 3. 5. etc nodes in the first/left column and 2. 4. 6. etc in the second/right column?
I am trying to figure the code out, but if someone could write it here, that would be really awesome!
I am quite new to XSL and have maybe a simple problem, but i am not sure what the best solution might be.
imagine a xml file:
<root>
<number> 1 </number>
<number> 2 </number>
<number> 3 </number>
<number> 4 </number>
<number> 5 </number>
</root>
I would like to put this numbers into a table with 2 columns.
imagine a table:
column1--column2
1------------------ 2
3------------------ 4
5---------
The point is, that i do not know how many numbers/table-cells there are. There might be 5 or 99.
So, is it possible to count the <number> nodes and automaticly put the 1. 3. 5. etc nodes in the first/left column and 2. 4. 6. etc in the second/right column?
I am trying to figure the code out, but if someone could write it here, that would be really awesome!
-
- Posts: 4
- Joined: Mon Jan 05, 2009 11:08 pm
Re: Table with 2 columns
<fo:table-body background-color="green">
<xsl:for-each
select="numb[position() < $tableLength + 1]">
<xsl:variable name="pos" select="position()"/>
<fo:table-row>
<fo:table-cell border="2">
<fo:block>
<xsl:choose>
<xsl:when test="../numb[$pos mod 2 > 0]">
<xsl:value-of select="../numb[$pos]"/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:choose>
<xsl:when
test="../numb[($pos + 1) mod 2 < 1]">
<xsl:value-of select="../numb[$pos + 1]"/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
<xsl:for-each
select="numb[position() < $tableLength + 1]">
<xsl:variable name="pos" select="position()"/>
<fo:table-row>
<fo:table-cell border="2">
<fo:block>
<xsl:choose>
<xsl:when test="../numb[$pos mod 2 > 0]">
<xsl:value-of select="../numb[$pos]"/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:choose>
<xsl:when
test="../numb[($pos + 1) mod 2 < 1]">
<xsl:value-of select="../numb[$pos + 1]"/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service