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

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


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:

Current Thread