Subject: Re: [xsl] for-each -- strange multiplication effects From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 16 Jan 2001 13:49:27 GMT |
> this should only happen once! It does only happen once. That is, each time you execute <xsl:for-each select="//test[@x]"> only one node is selected. However you have this in the template for test and you haven't any other templates defined so you get the default template applied for the root "/" this just applies templates to the children of /. You haven't a template for doc so the default is again applied, and again templates are applied to each of the child nodes. So your template is then applied to each of the test nodes. As your template for test is <xsl:template match="test"> <xsl:for-each select="//test[@x]"> this should only happen once! <xsl:value-of select="@x"/> </xsl:for-each> </xsl:template> The result it generates does not depend on the actual node matched (the body of the template always searches the whole document again for test nodes) so you get the same output for each test node selected. Probably what you meant to have was <?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8"/> <xsl:template match="test[@x]"> this should only happen once! </xsl:template> <xsl:template match="test"/> </xsl:transform> David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Control Centre. For further information visit http://www.star.net.uk/stats.asp XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] for-each -- strange multiplic, mario . jeckle | Thread | Re: [xsl] for-each -- strange multi, Jeni Tennison |
[xsl] Re: for-each -- strange multi, Dimitre Novatchev | Date | Re: [xsl] select="substring-before(, Jeni Tennison |
Month |