![]() |
XSLT: How to write "Yes" if element/attribute exist or "no" if not?
The solutions for the following problems seems to be simple but I did not found a (convenient) solution:
Assume we have a number of elements of the same type under a common parent e.g. <person ... myattr="aaa">Paul</person> <person ... myattr="bbb">Peter</person> <person ... myattr="ccc">Karl</person> ..... <person ... myattr="ddd">Stan</person> Now I want to write a text from inside an XSLT script with the following conditions: 1.) Write "yesccc" (e.g. into file) if an element <person> with an attribute value myattr="ccc" exist otherwise write "noccc" 2.) Write "yesMick" (e.g. into file) if an element <person> with a value <person ...>Mick</person> exist otherwise write "noMick" 2.) Write "yesAttrib" (e.g. into file) if an element <person> have an attrib myattrib="....." defined (value unimportant) otherwise write "noAttrib" Thank you for your help Mark |
Re: XSLT: How to write "Yes" if element/attribute exist or "no" ifnot?
Mark Richards wrote: > The solutions for the following problems seems to be simple but I did > not found a (convenient) solution: Assume we have a number of > elements of the same type under a common parent e.g. > > > <person ... myattr="aaa">Paul</person> <person ... > myattr="bbb">Peter</person> <person ... myattr="ccc">Karl</person> > .... <person ... myattr="ddd">Stan</person> > > > Now I want to write a text from inside an XSLT script with the > following conditions: > > 1.) Write "yesccc" (e.g. into file) if an element <person> with an > attribute value myattr="ccc" exist otherwise write "noccc" <xsl:choose> <xsl:when test="//person[@myattr = 'ccc']"> <xsl:text>yesccc</xsl:text> </xsl:choose> <xsl:otherwise> <xsl:text>noccc</xsl:text> </xsl:otherwise> </xsl:choose> -- Martin Honnen http://JavaScript.FAQTs.com/ |
| All times are GMT. The time now is 12:34 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.