This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: IF-Test.....continued
- From: Wendell Piez <wapiez at mulberrytech dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 14 Mar 2002 18:31:23 -0500
- Subject: RE: [xsl] IF-Test.....continued
- References: <20020312112850.67053.qmail@web21303.mail.yahoo.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Laksh--
Also, you have to create an element before you can add an attribute.
So you need something like
<xsl:template match="Book">
<xsl:copy> <!-- copies the Book element -->
<xsl:copy-of select="@*"/> <!-- copies the attributes it has -->
<xsl:if test="not(@ISBN)"> <!-- adds an attribute when ISBN is missing -->
<xsl:attribute name="NOCODE">
<xsl:text>B01</xsl:text>
</xsl:attribute>
</xsl:if>
</xsl:copy>
</xsl:template>
At 08:24 AM 3/12/2002, Mike wrote:
>Well, match="book" won't match an element called <Book>
[after you had written]
> > Well,i've enclosed the template rule which involves IF
> > test.
> >
> >
> > <xsl:template match="book">
> > <xsl:if test="not(@ISBN)">
> > <xsl:attribute name="NOCODE">
> > <xsl:text>B01</xsl:text>
> > </xsl:attribute>
> > </xsl:if>
> > </xsl:template>
> >
> > The Book element has the following format
> > <Book NAME="book-name" AUTHOR="author-name"
> > ISBN="91-6637-401-7"/>
> >
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
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