Hi List.
I am trying to remove some Hierarchy in a document but can't seem to
preserve text content.
I have this kind of xml document (simplified...)
<xml>
<para>
<phrase role="rtf">
norepinephrine
</phrase>
<phrase role="rtf">
transporter<subscript/>
<emphasis>(h) </emphasis>
</phrase>
<phrase role="rtf">
(antagonist radioligand)
</phrase>
</para>
</xml>
I would like to remove the intermediary <phrase> nodes to avoid line
breaks (which are highly desirable on other places, but here are
annoying me), and thus having everything on a single line (using the
docbook stylesheets, already customized).
Thus I want
<xml>
<para>
<phrase role="rtf">
norepinephrine transporter
<subscript/>
<emphasis>(h) </emphasis>
(antagonist radioligand)
</phrase>
</para>
</xml>
I have tried with some copy templates
<xsl:template match="para">
<phrase>
<xsl:if test=".//phrase[@role='rtf']">
<xsl:attribute name="role">rtf</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</phrase>
</xsl:template>
<xsl:template match="phrase[@role='rtf']" >
<xsl:copy>
<xsl:apply-templates select="./*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy>
</xsl:template>
But the result I get is
<?xml version="1.0" encoding="UTF-8"?>
<phrase role="rtf">
<phrase/>
<phrase><subscript/><emphasis>(h)
</emphasis></phrase>
<phrase/>
</phrase>
Which is absolutely not what I want...
Any clever hint on how I should proceed ?
Thank you in advance
Best regards,
Fabien
--~------------------------------------------------------------------
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>
--~--