Reputation: 1147
I have an xml file on which I am applying transformation to a specific element and then try to get the text() of all the child nodes ignoring same node
<xml>
<xrefline>
<query>eligible individual</query>
in respect of a qualified dependant at any time means a person who at that time
<quote>
<para>
<n>(a)</n>
<parap>resides with the qualified dependant,</parap>
</para>
</quote>
</xrefline>
</xml>
My xslt template looks like this and I want to extract all the text() and preserve the query element
<xsl:template match="query" >
<xsl:apply-templates select="../text()|../node()[self::query]|../node()[not(self::query)]/text()" ></xsl:apply-templates>
</xsl:template>
My desire output should be like this
<xml>
<xrefline>
<query>eligible individual</query>
in respect of a qualified dependant at any time means a person who at that time (a) resides with the qualified dependant,
</xrefline>
</xml>
I have to work it around the template match="query"
and then go back to get the desire result. With my above xslt I am getting text which is out side the element quote but not the text of sub childs of quote element... any help or hint will be really helpful.
Upvotes: 2
Views: 1621
Reputation: 167736
I would write two templates:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xrefline//*[not(self::query)]">
<xsl:apply-templates/>
</xsl:template>
see http://xsltransform.net/948Fn5h.
Upvotes: 3