[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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 |
Hi, 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="*"> <type> <element name="productDesc"> <type> <element name="purpose" type="string"/> <element name="manufacturer" type="string"> <type> <element name="name" type="string"/> <element name="region" type="string"> <type> <element name="country" type="string"/> <element name="city" type="string"/> </type> </element> </type> </element> </type> </element> </type> </element> </type> 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 recursively? 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"/> </xsl:if> --> </xsl:for-each> </xsl:element> <xsl:apply-templates/> </xsl:template> I am a newbie to Xalan, so I would really appreciate any help. Thanks. Regards Bon XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: How to do numeric validations i, Kay Michael | Thread | XSLT processors performance/complia, James Tauber |
Re: selection with multiple keys, David_Marston | Date | XSLT processors performance/complia, James Tauber |
Month |