[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Test for leaf node

Subject: RE: Test for leaf node
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Tue, 14 Dec 2004 15:40:58 +0100
xsl test
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.