Subject: [xsl] Elements with Mixed contents From: "Sandeep Deshpande" <2dsan@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 14 Feb 2002 19:08:29 +0530 |
Hi All, I have a problem with the elements having mixed content. The problem is as follows. ======= XML File (x.xml ) ================ <?xml-stylesheet type="text/xsl" href="x.xsl"?> <directory>Hi I am in a directory. <subdirectory>Hi I am in a subdirectory. <file>Hi I am in file1.</file> in between two files (back to subdirectory.) <file>Hi I am in file2.</file> in between two files (back to subdirectory.) <file>Hi I am in file3.</file> out of file. back to subdirectory.</subdirectory> out of subdirectory. back to directory.</directory> ================================ ======= XSL File (x.xsl ) ================ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html><body> <xsl:apply-templates/> </body></html> </xsl:template> <xsl:template match="directory"> <br/><xsl:value-of select="text()"/><br/> <xsl:apply-templates select="subdirectory"/> <br/><xsl:value-of select="text()[1]"/><br/> </xsl:template> <xsl:template match="subdirectory"> <font color="red"> <br/><xsl:value-of select="text()"/><br/> <xsl:apply-templates select="file"/> <br/><xsl:value-of select="text()[1]"/><br/> <br/><xsl:value-of select="text()[2]"/><br/> </font> </xsl:template> <xsl:template match="file"> <font color="blue"> <br/><xsl:value-of select="."/></font><br/> </xsl:template> </xsl:stylesheet> ==================================== ======= Expected output ================ Hi I am in a directory. Hi I am in a subdirectory. Hi I am in file1. in between two files (back to subdirectory.) Hi I am in file2. in between two files (back to subdirectory.) Hi I am in file3. out of file. back to subdirectory. out of subdirectory. back to directory. ==================================== ======= ACTUAL OUTPUT ON IE5 ================ Hi I am in a directory. Hi I am in a subdirectory. Hi I am in file1. Hi I am in file2. Hi I am in file3. in between two files (back to subdirectory.) in between two files (back to subdirectory.) out of subdirectory. back to directory. ==================================== My problems :- 1) I can not place the data occurring between two child elemet properly. For e.g. in between two files (back to subdirectory.) ). 2) I have to keep a counter in XSL, for the data patches of the parent element occurring in between the child elements. ( For e.g. <br/><xsl:value-of select="text()[2]"/><br/> ). In big size data it is impossible to know how many data patches occur in between the child elements. If any of the gurus could get the solution of any of these problems, I would be grateful. Thanks & Regards Sandeep Deshpande Datamatics Technologies Limited Ph: 91-022-8290829 ( Ext: 617 ) SDF IV, SEEPZ, Mumbai-400 096, INDIA. Email: 2dsan@xxxxxxxxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] simple method for listing, DPawson | Thread | Re: [xsl] Elements with Mixed conte, Jeni Tennison |
RE: [xsl] alternate row color in a , Andrew Welch | Date | RE: [xsl] match on attribute anywhe, Andrew Welch |
Month |