xsl empty element: how to do?

A

adrian

Hi

I'm having the following problem:

im my xml file there is an element called <gebdatum>22.09.79</gebdatum>
(date of birth in english). this might be full (like in the example) or
empty.
in case it is empty I want to have some text saying that this data is
missing.

I tried like this but it only shows me that text "Keine Daten
vorhanden", but not the data where it exists:
_____________________________________________
<xsl:for-each select="gebdatum">

<xsl:if test="gebdatum=(.!='') ">

<font color="green">Keine Daten vorhanden!</font>

</xsl:if>

<xsl:if test="gebdatum!=(.!='') ">

<xsl:value-of select="gebdatum"/>

</xsl:if>

</xsl:for-each>
_______________________________________

I've also tried with
<choose>
<when>
</when>
<otherwise>
</otherwise>
<choose/>

and it didn't work too

What am I doing wrong?

Any help kindly regarded.

adrian
 
P

Peter Flynn

adrian said:
Hi

I'm having the following problem:

im my xml file there is an element called <gebdatum>22.09.79</gebdatum>
(date of birth in english). this might be full (like in the example) or
empty.
in case it is empty I want to have some text saying that this data is
missing.

I tried like this but it only shows me that text "Keine Daten
vorhanden", but not the data where it exists:
_____________________________________________

<xsl:template match="gebdatum">
<xsl:choose>
<xsl:when test=".=''">
<span class="nulldatum">Keine Daten vorhanden</span>
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="."/>
</xsl:eek:therwise>
</xsl:choose>
What am I doing wrong?

Trying too hard :) The simplest route is usually the best. This is the Tao
of XSLT :)

///Peter
 
T

toudidel

forget about xsl:for-each brrrr..... the best method of that checking is the
string-length() function using. You have to check: xsl:if
test="string-length(element/element/text())!=0". It guarantees performing in
cause of empty element and nonexisting element both.

td
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top