[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: testing the current node in IF statements
At 02:01 PM 2/4/00 -0000, Peter Bennet wrote: >what I really want to do now is use the same idea for the node itself >i.e.. > ><xsl:template match="book | chapter"> > <xsl:if test="self='book'"> > instructions > </xsl:if> > <xsl:if test="self='chapter'"> > different instructions > </xsl:if> > some instructions common to both ></xsl:template> >... Well, a way to do what you want would be to resort to string testing against the nefarious local-name(), as in: <xsl:template match="book | chapter"> <xsl:if test="local-name()='book'"> instructions </xsl:if> <xsl:if test="local-name()='chapter'"> different instructions </xsl:if> some instructions common to both </xsl:template> But a better way to achieve the same result might be to split your logic into separate templates after all: <xsl:template name="common-instructions"> some instructions common to both </xsl:template> <xsl:template match="book"> book instructions <xsl:call-template name="common-instructions"/> </xsl:template> <xsl:template match="chapter"> chapter instructions <xsl:call-template name="common-instructions"/> </xsl:template> Have fun-- Wendell Piez ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== 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
|