Jump to content

A layout problem


jojo_slash

Recommended Posts

Hi,I have written a xml file together with an xsl to display the order. The output displays in the explorer like this:Food (This is the topic)Apple(This is the title)It is red or green...... (This ................................ is................................ the................................ paragraph)Finally, it is something you should always eat.Orange(This is the title)It is orange............... (This ................................ is................................ the................................ paragraph)It is as good as apple and is something you should include in your eating habit.Drink (This is the topic)Milk(This is the title)It is a drink of............ (This ................................ is................................ the................................ paragraph)It is a drink that you should keep drinking everyday.and so forth.....(More than 20 topics) Now I am on the layout issue. My issue is depicted as follow:I want to display them in 2 columns and in rows(This means I am going to put them into tablel. This is fine for me ). But, each row only contain 10 lines. So if a paragraph contains more than 10 lines the 11th will be going to the next row or next column in the same row.The following are my expectation:Food___Column1_____| __Column2___ ___Apple_______| ___Orange____It is..................... | It is................................... | ...................................... | ..................................... | ...........Drink___Milk________| ___Softdrink____It is......................| It is ......................................| ..............................................|..............................................|..................If the paragraph more than 10 lines(suppose apple's paragraph exceed):Food___Column1_____| __Column2___ ___Apple_______| ................. (This is the 11th lines of apple's paragraph)It is..................... | ........................................ | ............. (This is the last line of apple's paragraph)........................... | __Orange____........................... | ................Can anyone suggest any solution? I can make the table using xsl but I don't know how to layout them in 10 lines for each row :) . Can anyone give an advise?

Link to comment
Share on other sites

Please try to speak in code. You're really consfusing by speaking with dots. As for your problem, you might want to try the linear to tabular data code.

The xsl structure is as follow: :) <xsl:stylesheet><xsl:template match="/"><html><head></head><body><center><h2>Good life Style</h2></center><xsl:apply-templates select="note/subject"/></body></html></xsl:template><xsl:template match="note"><xsl:apply-templates select="head_topic"/><xsl:apply-templates select="title"/></xsl:template><xsl:template match="head_topic"><center><table border="0" width="50%" cellpadding="0" align="center"><tr><td width="20%"></td><td width="60%"><h2><xsl:value-of select="."/></h2></td><td width="20%"></td></tr></table></center></xsl:template><xsl:template match="title"><table border="0" width="50%" cellpadding="0" align="center"><xsl:if test="column = 0"><tr><td><xsl:apply-templates select="descs/desc"/></td></tr></xsl:if></table><table border="0" width="50%" cellpadding="0" align="center"><xsl:if test="column = 1"><tr><td width="50%"><xsl:apply-templates select="title_head"/><xsl:apply-templates select="descs/desc"/></td></tr></xsl:if></table><table border="0" width="50%" cellpadding="0" align="center"><xsl:if test="column = 2"><tr><td><xsl:apply-templates select="title_head"/><xsl:apply-templates select="descs/desc"/></td></tr></xsl:if></table></xsl:template><xsl:template match="title_head"><span style="color:#0000ff"><xsl:value-of select="."/></span><br/></xsl:template><xsl:template match="desc"><xsl:for-each select="."><xsl:choose><xsl:when test="subdesc"><xsl:value-of select="definition"/><br/><ul><xsl:apply-templates select="subdesc"/></ul></xsl:when><xsl:otherwise>.<span style="color:#000000"><xsl:value-of select="."/></span><br/></xsl:otherwise></xsl:choose></xsl:for-each></xsl:template><xsl:template match="subdesc"><xsl:choose><xsl:when test="definition"><li><xsl:value-of select="definition"/></li><ul><xsl:apply-templates select="subdesclvl1"/></ul></xsl:when><xsl:otherwise><li><xsl:value-of select="."/></li></xsl:otherwise></xsl:choose></xsl:template><xsl:template match="subdesclvl1"><xsl:choose><xsl:when test="definition"><li><xsl:value-of select="definition"/></li><ul><xsl:apply-templates select="subdesclvl2"/></ul></xsl:when><xsl:otherwise><li><xsl:value-of select="."/></li></xsl:otherwise></xsl:choose></xsl:template><xsl:template match="subdesclvl2"><li><xsl:value-of select="."/></li></xsl:template></xsl:stylesheet>The following is my xml:<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="lifestyle.xsl"?><note><subject><topic> <head_topic>Food</head_topic> <title> <column>0</column> <descs> <desc>Food comprise of.....</desc> </descs> </title> <title> <column>1</column> <title_head>Fruit</title_head> <descs> <desc>Fruit......</desc> <desc>It is.......</desc> </descs> </title> <title> <column>2</column> <title_head>Vegetable</title_head> <descs> <desc>A major ...</desc> <desc> <definition>The main .... should:</definition> <subdesc>Follow ...</subdesc> <subdesc>If at all possible, ...</subdesc> <subdesc>Address the ...</subdesc> <subdesc>Be clear that ...</subdesc> <subdesc>Contain plenty ...</subdesc> <subdesc>Include ...</subdesc> </desc> <desc>You can...</desc> <desc>It is also imperative ...</desc> </descs> </title> <title> <column>1</column> <title_head>Meat</title_head> <descs> <desc>Following is a guide ...</desc> <desc> <definition>An introductory ... For example:</definition> <subdesc>The....</subdesc> <subdesc>or, start by ... For example:</subdesc> <subdesc>Check...</subdesc> <subdesc>In response ...</subdesc> </desc> <desc> <definition>If you are making ... For example:</definition> <subdesc>Prepare...</subdesc> <subdesc>Open...</subdesc> </desc> </descs> </title> <title> <column>2</column> <title_head>Some tips</title_head> <descs> <desc> <definition> </definition> <subdesc>Use a...</subdesc> <subdesc>Try not ...</subdesc> <subdesc>Avoid ...</subdesc> <subdesc>Do not use...</subdesc> <subdesc>Be ...</subdesc> <subdesc>Convey ...</subdesc> <subdesc>Highlight...</subdesc> <subdesc>Remember ...</subdesc> </desc> </descs> </title> <head_topic>Drink</head_topic> <title> <column>0</column> <descs> <desc>Everyday, you must...</desc> <desc>Its essential ...</desc> <desc>These days...</desc> </descs> </title> <title> <column>1</column> <title_head>Juice</title_head> <descs> <desc>If you...</desc> <desc>It is essential ...</desc> <desc> <definition>So, when ... For example:</definition> <subdesc>In your ...</subdesc> <subdesc>Your ...</subdesc> <subdesc>Your ...</subdesc> <subdesc>Your ...</subdesc> </desc> <desc>Even your hobbies ...</desc> </descs> </title> <title> <column>2</column> <title_head>Milk</title_head> <descs> <desc>It is...</desc> <desc>In other words...</desc> </descs> </title></topic></subject></note>It should note that the reason I put a column element under each title element is to layout them into two seperate column like the first post I have mentioned. I try many different ways but I stilll cannot get the expected output. :) It should be supposed that for the column element that contain 0 the contents should align center, while 1 indicates the alignment to the left and 2 to the right.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...