[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to check whether any of child node with particular
Hi All, I run into a problem where I'm not able to check whether any of child node with particular tag name has empty String value. Here's the XML: <ATTACHMENT> <ATTACHMENT_NAME></ATTACHMENT_NAME> <ATTACHMENT_LINK> http://yahoo.com </ATTACHMENT_LINK> <ATTACHMENT_NAME> link </ATTACHMENT_NAME> <ATTACHMENT_LINK> http://msn.com </ATTACHMENT_LINK> </ATTACHMENT> The requirement is to do something ANY of the <ATTACHMENT_NAME> elemement has non-empty String. Here's the XSL I wrote: <xsl:template match="ATTACHMENT"> <xsl:if test="string(normalize-space(child::ATTACHMENT_NAME))"> <P> <B>ATTACHMENT:</B> <xsl:for-each select="ATTACHMENT_NAME"> <xsl:variable name="href" select="following-sibling::ATTACHMENT_LINK" /> <a href ="{$href}"> <xsl:apply-templates /> </a> <br/> </xsl:for-each> </P> </xsl:if> </xsl:template> But from the result I got, seems like the decision is only based on the first <ATTACHMENT_NAME> element it found, and totally ignore the later ones. i.e. if the first <ATTACHMENT_NAME> has empty String value but the second one has String value "link" in it, it won't fall into the if block. Thanks in advance for any suggestions! Dongzhi XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|