Skipping xml entries with xsl

A

Andreas W. Wylach

Hello everybody,

i got a problem in building a xsl construct to skip xml entries. Xml
looks like this:

....
<textblock>
<text_crlf></text_crlf>
<text_crlf></text_crlf>
<text_crlf></text_crlf>
<text_crlf></text_crlf>
<text_crlf></text_crlf>
<text_crlf></text_crlf>
</textblock>
....

Above xml code is a little part out of a whole xml tree. The problem
i try to solve is to print out the first text_crlf tag (which will be
translated in <br> via a match function. All the following text_crlf
entries should be skipped, _if_ they are empty.
I tried to work with following/preceding-sibling and such but can't get it
to work.
I am not very xml expirienced, so maybe one of you wizards can give me a hint
how to get that problem solved.

Greetings
Andreas W. Wylach
aw (at) ioc3.de
 
A

Alex Shirshov

Hello, Andreas!
You wrote on 15 Apr 2004 01:55:32 -0700:

AWW> i got a problem in building a xsl construct to skip xml entries. Xml
AWW> looks like this:

AWW> ...
AWW> <textblock>
AWW> <text_crlf></text_crlf>
AWW> <text_crlf></text_crlf>
AWW> <text_crlf></text_crlf>
AWW> <text_crlf></text_crlf>
AWW> <text_crlf></text_crlf>
AWW> <text_crlf></text_crlf>
AWW> </textblock>
AWW> ...

AWW> Above xml code is a little part out of a whole xml tree. The problem
AWW> i try to solve is to print out the first text_crlf tag (which will be
AWW> translated in <br> via a match function. All the following text_crlf
AWW> entries should be skipped, _if_ they are empty.
AWW> I tried to work with following/preceding-sibling and such but can't
AWW> get it to work.
AWW> I am not very xml expirienced, so maybe one of you wizards can give me
AWW> a hint how to get that problem solved.

<xsl:template match="text_crlf[1]">
<br>
</xsl:template>

<xsl:template match="text_crlf[position() != 1 and . = '']"/>

<xsl:template match="text_crlf[position() != 1 and . != '']">
<!-- do some stuff here -->
</xsl:template>

With best regards, Alex Shirshov.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top