Jump to content

jojo_slash

Members
  • Posts

    14
  • Joined

  • Last visited

jojo_slash's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. 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.
  2. Is it PHP the only way? I am not familiar using PHP. As I just want to make it better looking I wonder whether CSS or XSL can help in the specified problem.
  3. apologize for that. I am not sure which board should it go to...I regret for doing that.
  4. 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?
  5. 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 sentences for each row . I think the solution only underlying on JavaScript. Can anyone give an advise?
  6. jojo_slash

    A layout issue

    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 sentences for each row . I think there is a solution underlying on CSS. Can anyone give an advise?
  7. 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 sentences for each row . I think the solution only underlying on JavaScript. Can anyone give an advise?
  8. Hi all,I try to type in language other than English in the xml file and it does not work. Is it possible to be done so and how to do that. Please advise.
  9. Hi I found that some site(like eldergreek) will show advertisment when you put your mouse arrow over some definition words and the advertisment describe the word. How do they do that? Is it possible to do that just using html? Please advise. Thanks!
  10. Hi Is it possible to include some piece of data with superscript or subscript into the xml file? Please advise how and if impossible otherwise. Thanks!
  11. Under the new codes you gave me, I found the outcome has improved. The contents has been shown. I think I can do some adjustment to make it the way I want now. Thank you for your hard work. Btw, to help you into the investigation, I put the tag that I have used in my codes as follow: tag 1= headtag 2= titletag 3= descriptiontag 4= blocktag 5= linktag 6= name_linkHope it is useful to you.
  12. Thank you for the reply. I found that the structure of the xsl makes more sense than it was. I loaded the xml to see what I got and found that only the Topic and Title is shown only(the contents all missing). As I am not very clear about the difference between absolute and relative value(just know a bit more about absolute that exact path must be used), I try both way you gave me to see if I have been putting incorrect value into the XPath link but could not find out that way. Why would the contents become missing? (I really don't understand since after I read the structure you set up in my xsl I think it is perfectly make sense and correct). I posted my latest codes again: Here is my xml:<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="try.xsl"?><note><subject><tag1>topic1</tag1><tag4><tag2>title1: </tag2><contents><tag3>content1</tag3><tag3>content2</tag3><tag3>content3</tag3><tag3>content4</tag3><tag3>content5</tag3><tag3><tag5>C://Webdocs/java.html</tag5><tag6>content5</tag6></tag3></contents></tag4><tag4><tag2>title2:</tag2><contents><tag3>content1</tag3><tag3>content2</tag3></contents></tag4></subject></note>Here is my xsl:<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h2>My note</h2><xsl:apply-templates/></body></html></xsl:template><xsl:template match="subject"><p><xsl:apply-templates select="tag1"/><xsl:apply-templates select="tag4"/></p></xsl:template><xsl:template match="tag1">Topic: <xsl:value-of select="."/><br/></xsl:template><xsl:template match="tag2">Title: <span style="color:#ff0000"><xsl:value-of select="."/></span><br /></xsl:template><xsl:template match="tag3"><xsl:choose><xsl:when test="tag5"><a><xsl:attribute name="href"><xsl:value-of select="/topic/contents/tag5" /></xsl:attribute><xsl:value-of select="/topic/contents/tag6" /></a><br/></xsl:when><xsl:otherwise>Content: <span style="color:#00f000"><xsl:value-of select="."/></span><br/></xsl:otherwise></xsl:choose></xsl:template><xsl:template match="tag4"><xsl:apply-templates select="tag2" /><xsl:apply-templates select="tag3" /></xsl:template></xsl:stylesheet>Thank you for reading the codes again I see another question of interest is if I deleted the <xsl:template match="subject">...</xsl:template> there will be no difference on the outcome. Do I write up something that is not necessary in my xsl?
  13. First, thanks you for comments. I am using "tag" as name because I think it is better to illustrate on my question of interest. My final version will not be using that as the element's name. I had read the link you refer to before I post the question. But I am a slow learner and just start learning xml and xsl. I do not understand much the technical area(I did not know that post is related to my issue if you did not point out) .However, I still cannot solve the problem after trying to imitate the style of the code into my own. Here is the latest code:Here is my xml:<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="try.xsl"?><topic><tag4><tag2>title1: </tag2><contents><tag3>content1</tag3><tag3>content2</tag3><tag3>content3</tag3><tag3>content4</tag3><tag3>content5</tag3><tag5>C://Webdocs/java.html</tag5><tag6>content5</tag6></contents></tag4><tag4><tag2>title2:</tag2><contents><tag3>content1</tag3><tag3>content2</tag3></contents></tag4></topic>Here is my xsl:<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><h2>My note</h2><xsl:apply-templates/><a> <xsl:attribute name="href"> <xsl:value-of select="/contents/tag5" /> </xsl:attribute> <xsl:value-of select="/contents/tag6" /></a></body></html></xsl:template><xsl:template match="subject"><p><xsl:apply-templates select="tag1"/><xsl:apply-templates select="tag2"/> <xsl:apply-templates select="tag3"/></p></xsl:template><xsl:template match="tag1">Topic: <xsl:value-of select="."/><br/></xsl:template><xsl:template match="tag2">Title: <span style="color:#ff0000"><xsl:value-of select="."/></span><br /></xsl:template><xsl:template match="tag3">.<span style="color:#00f000"><xsl:value-of select="."/></span><br/></xsl:template></xsl:stylesheet>The result of that is it turn up the hyperlink and the word used for the link shown after content 5. This show that I do not understand the way the attribute is used. I think I am out of the track. Looking toward your reply.
  14. Here is my xml abstract:<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="xml_qtynote.xsl"?><note><subject></subject><topic> <tag1>topic </tag1> <tag2>title1: </tag2> <tag3>content1</tag3> <tag3>content2</tag3> <tag3>content3</tag3> <tag3>content4</desc> <tag3>content5</tag3> <tag2>title2:</tag2> <tag3>content1</tag3> <tag3>content2</tag3></topic></note>--------------------------------------------Here is my xsl abstract:<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><head><h2>My note</h2><xsl:apply-templates/></body></html></xsl:template><xsl:template match="subject"><p><xsl:apply-templates select="tag1"/><xsl:apply-templates select="tag2"/> <xsl:apply-templates select="tag3"/></p></xsl:template><xsl:template match="tag1">Topic: <xsl:value-of select="."/><br/></xsl:template><xsl:template match="tag2">Title: <span style="color:#ff0000"><xsl:value-of select="."/></span><br /></xsl:template><xsl:template match="tag3">.<span style="color:#00f000"><xsl:value-of select="."/></span><br/></xsl:template></xsl:stylesheet>----------------------------------------------I want to select content5 from tag3 element and make it shown as a hyperlink in html. I try it by assigning a attribute into the tag3 with content5 in the xml and use the conditional statement in xsl but found that doesn't work. Is it possible to do? How? I am just learning xml and xsl in the Tutorial and cannot find out the answer. Can someone help? Thanks! :)If you have any comments about the structure of my xml and xsl, please give advise. Thanks!
×
×
  • Create New...