Subject: Re: [xsl] Not parsing sub-nodes From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Fri, 9 Mar 2001 09:36:27 +0000 |
Hi Roshan, > <xslt:transform xmlns:xslt="http://www.w3.org/1999/XSL/Transform" version="1.0">> > > <xsl:template match="/*"> > <xsl:value-of select="."/> > <xsl:for-each select="company"> > <xsl:apply-templates select="company"/> > </xsl:for-each> > </xsl:template> > > <xsl:template match="office"> > <xsl:value-of select="."/> > <xsl:apply-templates select="office"/> > </xsl:template> The first problem is that the namespace prefix that you've declared for the XSLT namespace ('xslt') isn't the one that you're using on the templates in the stylesheet (where you're using 'xsl' instead). Those need to be in sync. The second thing is that you seem to be misunderstanding how xsl:apply-templates works. The path that you give in the select attribute of xsl:apply-templates is resolved relative to the *current node*. In the xsl:for-each in the first template, then the current node is a 'company' element (a child of the document element, which in your case seems to be company 'Uno'). The company elements that are iterated over by the xsl:for-each are therefore the companies 'Duo', 'Tres' and 'Quatro'. The xsl:apply-templates then applies templates to the company element children of these company elements - there aren't any, so no templates get applied. In the xsl:template for the office, again you apply templates to the 'office' children of the current office. You don't appear to have nested offices inside one another, so again the processor won't find anything to apply templates to. What you're after is something along the lines of: <xsl:template match="company"> <!-- give the name of the company --> <xsl:value-of select="@name" /> <!-- apply templates to its office child --> <xsl:apply-templates select="office" /> <!-- apply templates to any company children --> <xsl:apply-templates select="company" /> </xsl:template> <xsl:template match="office"> <!-- give the location of the office --> <xsl:value-of select="@location" /> </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Not parsing sub-nodes, David Carlisle | Thread | [xsl] xsl unique position, mat t |
Re: [xsl] Not parsing sub-nodes, David Carlisle | Date | [xsl] XSL tranformation performance, Tara Chatterton |
Month |