Subject: Re: please help: why <xsl:foreach select="node()"> not works here? From: Mike Brown <mike@xxxxxxxx> Date: Wed, 24 May 2000 23:48:46 -0600 (MDT) |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
please help: why <xsl:foreach selec, Jia Ming Li | Thread | ANN: 4XPath 0.9.0 and 4XSLT 0.9.0, uche . ogbuji |
ANN: 4XPath 0.9.0 and 4XSLT 0.9.0, uche . ogbuji | Date | Re: multi language support, Sydney |
Month |