473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

xsl empty element: how to do?

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

Aug 24 '05 #1
2 4706
adrian wrote:
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:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
What am I doing wrong?


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

///Peter
Aug 24 '05 #2
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
Aug 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Derek Basch | last post by:
Hello All, I ran into a problem while dynamically constructing XHTML documents using minidom. If you create a script tag such as: script_node_0 = self.doc.createElement("script")...
13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
13
by: vega | last post by:
How do I detect empty tags if I have the DOM document? For example: <br /> and <br></br> I tried org.w3c.dom.Node.getFirstChild(), it returns null for both <br /> and <br></br> I also tried...
18
by: Neal | last post by:
According to the specs (http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to 4.01, it won't validate,...
3
by: Lukas | last post by:
title: xml to xml mapping: empty elements output although input element is not empty Why is is that when mapping from a XML schema to another XML schema, when drawing a default connection...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
1
by: tMan | last post by:
whats the xpath to get all the empty nodes in a document. in the xml below i want to get the nodes <empty> and <t> all other nodes either have a child node or text in them <root> <test> <se>...
5
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail...
7
by: kumar.senthil | last post by:
Hi, I'm using XmlSerializer to create an object from the XML string. I would like to know whether I can get a null value for an empty XML element. Actually the XmlSerializer assigns "" (empty...
1
by: DrDavey | last post by:
What are the advantages/disadvantages of using a choice of a several "sub-"elements with empty content (and no attributes) vs. simple content. Here's an example: Using simple content:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.