Click here to Skip to main content
15,912,665 members
Home / Discussions / XML / XSL
   

XML / XSL

 
Questionxml stylesheet to customize Excel - How to change column width Pin
umakemesik18-Sep-07 11:59
umakemesik18-Sep-07 11:59 
AnswerRe: xml stylesheet to customize Excel - How to change column width Pin
Ed.Poore18-Sep-07 12:44
Ed.Poore18-Sep-07 12:44 
QuestionHelp need for XSL file Pin
_anil_17-Sep-07 23:03
_anil_17-Sep-07 23:03 
QuestionProblem with SQL Server bulk load XML def Pin
mintxelas17-Sep-07 22:44
mintxelas17-Sep-07 22:44 
Questionlimited iteration Pin
TClarke14-Sep-07 2:11
TClarke14-Sep-07 2:11 
AnswerRe: limited iteration Pin
George L. Jackson14-Sep-07 11:43
George L. Jackson14-Sep-07 11:43 
GeneralRe: limited iteration Pin
TClarke17-Sep-07 0:28
TClarke17-Sep-07 0:28 
GeneralRe: limited iteration [modified] Pin
George L. Jackson17-Sep-07 9:57
George L. Jackson17-Sep-07 9:57 
Your XML was not valid so I used the following:

<?xml version="1.0" ?>
<ROWDATA>
<ROW>
<TABLE_ROW_DETAILS>XSL-FO to describe the row of a table</TABLE_ROW_DETAILS>
<BLOCKSEQUENCE>1</BLOCKSEQUENCE>
</ROW>
<ROW>
<TABLE_ROW_DETAILS>to describe the row of a table</TABLE_ROW_DETAILS>
<BLOCKSEQUENCE>2</BLOCKSEQUENCE>
</ROW>
<ROW>
<TABLE_ROW_DETAILS>to describe the row of a table</TABLE_ROW_DETAILS>
<BLOCKSEQUENCE>3</BLOCKSEQUENCE>
</ROW>
<ROW>
<TABLE_ROW_DETAILS>to describe the row of a table</TABLE_ROW_DETAILS>
<BLOCKSEQUENCE>1</BLOCKSEQUENCE>
</ROW>
<ROW>
<TABLE_ROW_DETAILS>to describe the row of a table</TABLE_ROW_DETAILS>
<BLOCKSEQUENCE>2</BLOCKSEQUENCE>
</ROW>
<ROW>
<TABLE_ROW_DETAILS>to describe the row of a table</TABLE_ROW_DETAILS>
<BLOCKSEQUENCE>1</BLOCKSEQUENCE>
</ROW>
</ROWDATA>

For illustration, I transformed this XML to HTML into 3 sets of tables. The key to the
transformation is to get the first following sibling of ROW "following-sibling::ROW[1]" and the "blocksequence" parameter that stops the recursion when BLOCKSEQUENCE does not equal it.

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="ROWDATA/ROW[BLOCKSEQUENCE = 1]" mode="page"/>
</body>
</html>
</xsl:template>
<xsl:template match="ROW" mode="page">
<table class="page">
<xsl:apply-templates select="." mode="row">
<xsl:with-param name="blocksequence" select="1"/>
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="ROW" mode="row">
<xsl:param name="blocksequence"/>
<xsl:if test="$blocksequence = BLOCKSEQUENCE">
<tr>
<td><xsl:value-of select="BLOCKSEQUENCE"/><xsl:text>: </xsl:text></td>
<td><xsl:value-of select="TABLE_ROW_DETAILS"/></td>
</tr>
<xsl:apply-templates select="following-sibling::ROW[1]" mode="row">
<xsl:with-param name="blocksequence" select="$blocksequence + 1"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Output:

<html>
<body>
<table class="page">
<tr>
<td>1: </td>
<td>XSL-FO to describe the row of a table</td>
</tr>
<tr>
<td>2: </td>
<td>to describe the row of a table</td>
</tr>
<tr>
<td>3: </td>
<td>to describe the row of a table</td>
</tr>
</table>

<table class="page">
<tr>
<td>1: </td>
<td>to describe the row of a table</td>
</tr>
<tr>
<td>2: </td>
<td>to describe the row of a table</td>
</tr>
</table>

<table class="page">
<tr>
<td>1: </td>
<td>to describe the row of a table</td>
</tr>
</table>
</body>
</html>

"We make a living by what we get, we make a life by what we give." --Winston Churchill

-- modified at 16:27 Monday 17th September, 2007
GeneralRe: limited iteration Pin
TClarke3-Oct-07 4:11
TClarke3-Oct-07 4:11 
Questionxml to html with c# Help Please Pin
phillippio13-Sep-07 13:14
phillippio13-Sep-07 13:14 
AnswerRe: xml to html with c# Help Please Pin
George L. Jackson14-Sep-07 1:48
George L. Jackson14-Sep-07 1:48 
GeneralRe: xml to html with c# Help Please Pin
phillippio14-Sep-07 11:11
phillippio14-Sep-07 11:11 
GeneralRe: xml to html with c# Help Please Pin
George L. Jackson14-Sep-07 11:39
George L. Jackson14-Sep-07 11:39 
QuestionWriting xml as a DiffGram Pin
steve_rm12-Sep-07 21:50
steve_rm12-Sep-07 21:50 
QuestionWant to use xml as localdatabse Pin
manuo512-Sep-07 0:01
manuo512-Sep-07 0:01 
QuestionXML file format Pin
VK-Cadec11-Sep-07 2:21
VK-Cadec11-Sep-07 2:21 
AnswerRe: XML file format Pin
George L. Jackson11-Sep-07 14:17
George L. Jackson11-Sep-07 14:17 
GeneralChoice of Value Types in Field Pin
Brady Kelly11-Sep-07 1:38
Brady Kelly11-Sep-07 1:38 
Questionhow to use the distinct-nodes function? Pin
Rocky#11-Sep-07 0:30
Rocky#11-Sep-07 0:30 
Questiongeneralizing the tabular display of xml data Pin
Rocky#10-Sep-07 20:23
Rocky#10-Sep-07 20:23 
QuestionHow to XSL parse 300 mg XML file? Pin
mcsdgal7-Sep-07 8:21
mcsdgal7-Sep-07 8:21 
NewsReding xml node in windows Forms [modified] Pin
chakran6-Sep-07 1:10
chakran6-Sep-07 1:10 
GeneralRe: Reding xml node in windows Forms Pin
Chetan Patel7-Sep-07 2:39
Chetan Patel7-Sep-07 2:39 
AnswerRe: Reding xml node in windows Forms Pin
israr Ali .NET7-Sep-07 2:39
israr Ali .NET7-Sep-07 2:39 
QuestionCalling a template recursively?? Pin
Rocky#5-Sep-07 0:23
Rocky#5-Sep-07 0:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.