This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: nested templates?


David,
I'm not sure what Alex meant but it clicked with me.
<thing>
	<meta>
		<title>Something</title>
	<meta>
	<body>
		<section>
			<title>Some Title</title>
		</section>
	</body>
</thing>

<xsl:stylesheet>
	<xsl:template match="meta">
		some meta stuff
		<xsl:template match="title">
			vo .
		</xsl:template>
	</xsl:template>
	<xsl:template match="body">
		...
		<xsl:template match="title">
			vo .
		</xsl:template>
	</xsl:template>
</xsl:stylesheet>

I know you can do

<xsl:stylesheet>
	<xsl:template match="meta">
		some meta stuff
		<xsl:template match="title">
			vo .
		</xsl:template>
	</xsl:template>
	<xsl:template match="body">
		...

	</xsl:template>
	<xsl:template match="body/title">
		vo .
	</xsl:template>
</xsl:stylesheet>

But sometimes it's easier to think more recursively and with scope and the
first makes that more apparent whereas the second (current way) seems rather
flat.
But hey that's the way it is.

Ciao Chris

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


>-----Original Message-----
>From: owner-xsl-list@lists.mulberrytech.com
>[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of David
>Carlisle
>Sent: 16 May 2001 19:34
>To: xsl-list@lists.mulberrytech.com
>Subject: Re: [xsl] nested templates?
>
>
>
>> The above seems to be illegal, though I can't think of a good reason why.
>
>It is clearly illegal, what would you want it to mean?
>I suspect that xsl:template does not operate the way you imagine.
>
>> is it possible to construct an xslt stylesheet that is more similar to a
>> "complete" page, i.e. with nested templates:
>
>It is possible to design a "complete page" this is what is sometimes
>called the pull method, in fact if you are doing that, you don't need
>any xsl;template instructions at all, see the XSLT spec for an example
>(or the FAQ for this list).
>
>
>> (btw, this is not syntactically complete, but you get the idea :)
>
>No, I can't imagine what the idea is! I think you are trying to
>do something like xsl:for-each but with an illegal use of xsl:template.
>It would be clearer if you said what you wanted to happen rather than
>posting some code you know to be wrong and then asking us to guess
>what you want it to do!
>
>David
>
>_____________________________________________________________________
>This message has been checked for all known viruses by Star Internet
>delivered through the MessageLabs Virus Scanning Service. For further
>information visit http://www.star.net.uk/stats.asp
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]