Subject: RE: please help: why <xsl:foreach select="node()"> not works here ? From: Jia Ming Li <jmingli@xxxxxxxx> Date: Thu, 25 May 2000 18:34:51 -0700 |
Thank you Mike, It works, thanks for your segguestions. -Ming. -----Original Message----- From: Mike Brown [mailto:mike@xxxxxxxx] Sent: Wednesday, May 24, 2000 10:49 PM To: xsl-list@xxxxxxxxxxxxxxxx Subject: Re: please help: why <xsl:foreach select="node()"> not works here? Jia Ming Li, You didn't mention what XSL processor you are using. Anyway, consider this part of your XML: <ROW> <A>a1</A> <B>b1</B> </ROW> It represents this subtree of nodes (note the whitespace, which I write here as \n for newline and \t for tab): element 'ROW' | |___text '\n\t\t\t' | |___element 'A' | | | |___text 'a1' | |___text '\n\t\t\t' | |___element 'B' | | | |___text 'b1' | |___text '\n\t\t' In your XSL you say: <xsl:for-each select="ROW"> <TR> <xsl:for-each select="node()"> But I think you want: <xsl:for-each select="ROW"> <TR> <xsl:for-each select="*"> or even "*/text()" instead of "*". Also, you may find XSLT to be more powerful if you use a design pattern in which repetitive processes get their own separate templates, rather than bloating one template with many xsl:for-each elements. For example: <xsl:template match="/"> <HTML> <HEAD> <TITLE>test</TITLE> </HEAD> <BODY> <xsl:apply-templates select="RESULT/DATA"/> </BODY> </HTML> </xsl:template> <xsl:template match="DATA"> <TABLE BORDER="2"> <xsl:apply-templates select="ROW"/> </TABLE> </xsl:template> <xsl:template match="ROW"> <TR> <xsl:for-each select="*"> <TD><xsl:value-of select="."/></TD> </xsl:for-each> </TR> </xsl:template> Also take note that ALL CAPITAL LETTERS for the names of HTML elements, while recommended up through HTML 4.01, is deprecated for XHTML 1.0 and higher. - Mike ___________________________________________________________ Mike J. Brown, software engineer, Webb Interactive Services XML/XSL stuff: http://www.skew.org/ http://www.webb.net/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: please help: why <xsl:foreach s, Kay Michael | Thread | URL decomposition, MarkH |
Xalan Samples, Carlos Sanchez | Date | How to escape character when using , Hien Luu |
Month |