RE: [xsl] applying different templates to one element, at differents result nodes

Subject: RE: [xsl] applying different templates to one element, at differents result nodes
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Fri, 29 Dec 2000 11:58:10 -0000
JS,
I don't see how yur example works as there is no result node in your input
to trigger your result template. What you want to achieve can probably be
done with modes.

<xsl:template match="card">
	<result>
		<xsl:apply-templates mode="head" />
		<newpage>
			<xsl:apply-templates mode="page" />
		</newpage>
	</result>
</xsl:template>
<xsl:template match="link" mode="head">
	<resulthead><xsl:value-of select="src" /> <xsl:value-of select="href"
/></resulthead>
</xsl:template>
<xsl:template match="link" mode="page">
	<newnode><xsl:value-of select="src" /></newnode>
</xsl:template>

Or some variation.

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Floch
>Jean-Sibastien
>Sent: 29 December 2000 09:04
>To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
>Subject: [xsl] applying different templates to one element, at
>differents result nodes
>
>
>Hello
>  I've a question for you all, and i hope you will
>help me
>
>  My xml is like this:
>
>  <page>
>    <card>
>      <link>
>        <src>1src1</src>
>        <href>1href1</href>
>      </link>
>      <link>
>        <src>2src2</src>
>        <href>2href2</href>
>      </link>
>      <link>
>        <src>3src3</src>
>        <href>3href3</href>
>      </link>
>    </card>
>  </page>
>
>
>
>  And i want as a result of xsl transformation
>something like:
>
>  <result>
>    <resulthead>1src1 1href1</resulthead>
>    <resulthead>2src2 2href2</resulthead>
>    <resulthead>3src3 3href3</resulthead>
>    <newpage>
>      <newnode>1src1</newnode>
>      <newnode>2src2</newnode>
>      <newnode>3src3</newnode>
>    </newpage>
>  </result>
>
>
>
>  But the way i want to do this is a little more
>complex than just using
>
>  <xsl:template match="result">
>  <resulthead>
>    <xsl:for-each select="//link">
>      <xsl:value-of select="src"/> <xsl:value-of
>select="href"/>
>    </xsl:for-each>
>    <xsl:apply-templates/>
>  </resulthead>
>  </xsl:template>
>
>  <xsl:template match="link">
>      <xsl:value-of select="src"/>
>  </xsl:template>
>
>  I know it works, but i can't use it in my context
>(obviously my real xml is not as simple as i wrote it
>upward)
>
>  The thing i really want to do is everytime i find a
>tag <link> in my xsl, i want to apply its template
>'where' i am,
>  but i want too apply an other template at the root
>node
>
>  Is there a way to do it?
>
>  Thanks,
>  Jean-Sebastien Floch
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Photos - Share your holiday photos online!
>http://photos.yahoo.com/
>
> 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