1. How do I check, in my .xsl file, if an element is empty? XSLT Questions and Answers (url:
)http://www.dpawson.co.uk/xsl/sect2/sect21.html) is a priceless source of information. In particular:
�How
to test if the value of a certain node is empty?
Depends what you mean by empty.
...
Contains no text content: not(
string(.))
Contains no text other than whitespace: not(normalize-space(.))
...�
2. Why do I keep getting the first element from my .xml file - I don't want it to be in my .html file. Hm. Your XML + XSL do not give any output at all on my computer...
However, when I changed
<xsl:apply-templates select="PERSON"> to
<xsl:apply-templates select="/PERSONS/PERSON"> the output is:
50
I suspect your template for PERSON was not called. (You can check it by inserting some text after <xsl:template>:
<xsl:template match="PERSON">
this is a string to indicate that this template was called
<xsl:value-of select="AGE"/> ...)
Instead, your XSLT processor used so-called �default templates� � special templates which have to be applied when there is no explicit template that matches an element. Default temlate simply outputs an element�s content. Of course, this begs question: why content of the PHONE element is skipped?
[This message has been edited by Mapraputa Is (edited June 11, 2001).]