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

How to find out the existence of an attribute and child node

Subject: How to find out the existence of an attribute and child nodes
From: "Truong, Bon" <btruong@xxxxxxxxxxx>
Date: Thu, 20 Jan 2000 11:36:47 -0800
xsl test for node existence


Recently, I downloaded Xalan 0.19.2.
I am looking into XSLT's capabilities to do schema transformations.
Below is a schema fragment I would like to convert to the XML doc,
which is defined in that schema fragment:

	 <type name="Items">
		<element name="Item1" minOccurs="0" maxOccurs="*">
				<element name="productDesc">
						<element name="purpose"
						<element name="manufacturer"
name="name" type="string"/>
name="region" type="string">
<element name="country" type="string"/>
<element name="city" type="string"/>

As you can see, the element "type" doesn't contain any attribute if it is a
child node of the element "element".
What is the expression of the attribute "test" in "xsl:if" I can use in
order to find out whether the element "type" contains the attribute "name"?
How I can check whether a given node such as "element" has any child nodes?
Is it possible to call a template matching exactly the same pattern
For example, '<element name="Item1" minOccurs="0" maxOccurs="*">' contains a
child node '<type>'.
I would like to call a template recursively such as follows:

	<xsl:template match="type">
		    <xsl:element name="{@name}">	        
			<xsl:for-each select="element">		     
			     <xsl:element name="{@name}"/>
			     <xsl:element name="{@ref}"/>
			<!-- Is this valid?
			     <xsl:if test="node()=type">
			     	<xsl:apply-templates select="type"/>

I am a newbie to Xalan, so I would really appreciate any help.



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

Current Thread


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.
First Name
Last Name
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.