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]

A better solution...


Hi *,

I would like to know if it's possible to find a better solution for this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="html" omit-xml-declaration="yes" indent="no"/>

	<xsl:param name="S"/>

	<xsl:template match="/Sections">
		<xsl:for-each select="//Section[@Title=$S][1]">
			<xsl:call-template name="SubS"/>
		</xsl:for-each>
	</xsl:template>

	<xsl:template name="SubS" match="Section">
		<!- ... -->
	</xsl:template>

</xsl:stylesheet>

This applies the 2nd template to the first occurrence of node Section with
attribute Title equal to the parameter S.

The XML looks like this (sections can be nested up to any level):

<Sections>
	<Section Title="1">
		<Section Title="2"/>
		<Section Title="4"/>
		<Section Title="8">
			<Section Title="9"/>
		</Section>
	</Section>
	<Section Title="3">
		<Section Title="2"/>
	</Section>
	...
</Sections>

What I don't like is to have to use a for-each to select the node.
Any ideas ?

Thanks in advance,
Frank.

 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]