RE: [xsl] Test for leaf node

Subject: RE: [xsl] Test for leaf node
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Tue, 14 Dec 2004 15:40:58 +0100
I used not(*) but it seems not to work here. What am I doing wrong? I
try with the following snippet:

1 copy the source doc without changes unless
2 a node is found that has a xs:element rule in an external xsd
2 the xs:element should only be chosen when it is empty and have a type
attribute e.g.<xs:element ... type=""/>
2 it should be stored into a variable xsd_node
3 when xsd_node is not empty further processing should be done


	<!-- 1 Identity-copy source document...  -->
	<xsl:template match="/ | @* | node()">

		<!-- 1 Store name of current element -->
		<xsl:variable name="name">
			<xsl:value-of select="name(.)"/>
		</xsl:variable>

		<!-- 2 Store matching xsd rule node in variable if
available -->
		<xsl:variable name="xsd_node">
			<xsl:copy-of select="$xsd_doc//xs:element[@name
= $name and not(*)]"/>
		</xsl:variable>

		<!-- ...until matching elment rule is found in the xsd
-->
		<xsl:copy>
			<xsl:choose>
				<xsl:when test="$xsd_node">
					<!-- 3 If element is empty but
marked as required in xsd... -->
					<EMPTY>
						<TEXT><xsl:value-of
select="text()"/></TEXT>
						<NODE><xsl:copy-of
select="$xsd_node"/></NODE>
						<MIN><xsl:copy-of
select="$xsd_node/@*"/></MIN>
						<xsl:apply-templates/>

					</EMPTY>

				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:copy>
	</xsl:template>

Can you help?

Regards,

Robert

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Dienstag, 14. Dezember 2004 15:09
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Test for leaf node



this is a FAQ.

> (maybe empty text() node?

text nodes (in xslt 1) are never empty.

 <xsl:if test="not(*)">

is true if there are no child elements.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. For more information on a proactive anti-virus
service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread