Jan,
Try this:
<xsl:template match="nl">
<xsl:if
test="normalize-space(following-sibling::node()[1][self::text()]))">
{\par }
</xsl:if>
</xsl:template>
What it does: it selects the node directly following the nl
(following-sibling::node()[1]), checks if it's a text node [self::text()],
and normalizes its space (collapses internal white space and trims leading
and trailing space). If anything is left, we know the nl is followed
directly by some text, so we generate the {\par }.
It may require adjusting if your data is a bit different.
It's not really deleting duplicate elements; rather it's a more
straightforward approach (only acting on them if we want them).
As for your English, I found two extremely minor errors in it. My posts
often contain more than this! good job.
Cheers,
Wendell
At 11:59 AM 4/15/2003, you wrote:
Hello everybody,
i need your help. i am using XSL to transform XML document into RTF
file.
i have this source tree from other company:
<book>
<name>
Text text text text
<nl/>
<nl/>
Text text text text
<nl/>
<nl/>
Text text text text
<nl/>
<nl/>
<name>
</book>
element <nl> is : "new line"
XSL for element <name> and <nl> is:
<xsl:template match="name">
{\par }{\qc \sa200\fs20\li500 {\b <xsl:apply-templates/>}
</xsl:template>
<xsl:template match="nl">
{\par }
</xsl:template>
Result tree is :
{\par }{\qc \sa200\fs20\li500 {\b Text text text text }
{\par }
{\par }
\par }{\qc \sa200\fs20\li500 {\b Text text text text }
{\par }
{\par }
\par }{\qc \sa200\fs20\li500 {\b Text text text text }
{\par }
{\par }
but i need only one tag {\par }. How can i do it? How can i replace two
<nl><nl> by one <nl>?
thanks and sorry for my English
Jan Zavoral
Czech Republic
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)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