View Single Post
  #2 (permalink)  
Old 12-05-2007, 11:45 AM
kgun's Avatar
kgun kgun is offline
WebProWorld 1,000+ Club
 

Join Date: May 2005
Location: Norway
Posts: 5,411
kgun RepRank 3kgun RepRank 3kgun RepRank 3
Default Re: XSLT Conditionals

Just worte about this today:

creating a .css file for xml - SitePoint Forums

Code:
<xsl:stylesheet version='1.0'
xmlns:xsl="http://w3.org/1999/XSL/Transform"
xmlns="http://w3.org/1999/xhtml"> 
 
<xsl:output method="xml" ...  />
 
</xsl:stylesheet>
is the way to do it. There is no output method=xhtml as I know of.

Quote:
Originally Posted by wige View Post
My question is, how do I test for a false condition? <xsl:if test="@name"> will execute if there is an attribute called name, but how can I get it to execute if name does not exist? The same thing applies with comparing values. If I want to check if name is not Tom, @name != 'Tom' does not work.
Generally you use this

axis::node test [predicats]

structure while filtering node sets. So you need to know the following concepts to perform tests:
  1. Axes
  2. node test (name test / node type test)
  3. Predicates that filters the node set.
Quote:
Originally Posted by wige View Post
Also, as part of the same issue, is there a way to get an XSL template to output an invalid tag? Basically, if an element is found without the specified tag, I want to output a closing tag, followed by a new opening tag. I am trying to create a new row in a table when this happens. However, the closing tag causes the file to no longer be valid XML, and it doesn't process. Do I need to use a CDATA container or something else?
CData shoul be able to do it. Depending on what you do (output method etc.) there can be problems with closing ?> etc. Last but not least, you need to know that white space (line feeds, carriage return, etc) may be interpreted different in various browsers. White space, you should know how that is handled from the very begining. It may be tricky.

Read more ...

Last edited by kgun : 12-05-2007 at 12:04 PM.
Reply With Quote