• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xls : statement of for each is null

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I im looking for a solution for this problem:
i have a XML file that can have many children and so on under a tag ("list1") ;
i make a table for those elements...

BUT how do i do if i want to type "No data in this event today.. " of the tag "list1" is empty?




have some one any ideas how to do this "properly" ?

Best regards to you all!
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well... you might have one or two questions there. So let's just answer both of them.

First: "How do I do if-then-else in XSLT?"

Answer: Use the <xsl:choose>, <xsl:when>, and <xsl:otherwise> elements. (I'm not going to go into details because you could read the documentation and find tutorials for those things. Much easier for both of us.)

Second: How do I use XSLT to find out whether a node exists?

You already know how to write an XPath expression which identifies the node. Coercing such an expression to boolean produces true if the node exists and false if not. So you can then write <xsl:if test="XPath expression"> or <xsl:choose test="XPath expression"> and follow that up with some code which will only be executed if the node exists. If your expression identifies more than one node, coercing it to boolean still returns true.
 
reply
    Bookmark Topic Watch Topic
  • New Topic