On 10/11/2010 10:07, srinivasan(_dot_)p(_at_)textech(_dot_)in wrote:
Hi Experts,
I need to select an element and store in a variable, but not the child
element of that particular element.
My XML
<book><title><indexterm>Violent Extremism</indexterm> Sacred Values, and
what it Means to be Human</title></book>
My XSLT:
<xsl:variable name="filename"><xsl:value-of select="book/title except
child::indexterm"/></xsl:variable>
Use
<xsl:variable name="filename" select="book/title"/>
Your code is wrong at several levels. book/title selects a single node
which is a title element; removing nodes called indexterm from that set
is a no-op because there aren't any. Then you are doing xsl:value-of
which takes the string value of the book/title node, which is defined as
the concatenation of its descendant text nodes. You said you wanted the
variable to contain the element, not to contain its string value.
My Current output:
Violent ExtremismSacred Values, and what it Means to be Human
My Expected output:
Sacred Values, and what it Means to be Human
The content of "indexterm" element should not be part of the file name. I
need to ignore that element while selecting the title element.
Use apply-templates to do a recursive descent of the tree rooted at the
title element. When you hit the indexterm element, don't descend down
that branch:
<xsl:template match="title">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="indexterm"/>
Michael Kay
Saxonica
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--