[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Removing nodes with text content ?
Subject: [xsl] Removing nodes with text content ? From: "Fabien Tillier" <f.tillier@xxxxxxxx> Date: Wed, 3 Aug 2011 16:14:08 +0200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] dynamic table in report, Mathis Mörke | Thread | Re: [xsl] Removing nodes with text , Andrew Welch |
Re: [xsl] dynamic table in report, G. Ken Holman | Date | Re: [xsl] Removing nodes with text , Andrew Welch |
Month |