How to implement if-else statement in XSLT?

I am trying to implement an if -else statement in XSLT but my code just doesn’t parse. Does anyone have any ideas? <xsl:variable name=”CreatedDate” select=”@createDate”/> <xsl:variable name=”IDAppendedDate” select=”2012-01-01″ /> <b>date: <xsl:value-of select=”$CreatedDate”/></b> <xsl:if test=”$CreatedDate > $IDAppendedDate”> <h2> mooooooooooooo </h2> </xsl:if> <xsl:else> <h2> dooooooooooooo </h2> </xsl:else> 5 Answers 5

XPath with multiple conditions

What XPath can I use to select any category with a name attribute specified and any child node author with the value specified. I’ve tried different variations of the path below with no success: //quotes/category[@name=”Sport” and author=”James Small”] The XML: <?xml version=”1.0″ encoding=”utf-8″?> <quotes> <category name=”Sport”> <author>James Small<quote date=”09/02/1985″>Quote One</quote><quote date=”11/02/1925″>Quote nine</quote></author> </category> <category name=”Music”> … Read more

How to execute XPath one-liners from shell?

Is there a package out there, for Ubuntu and/or CentOS, that has a command-line tool that can execute an XPath one-liner like foo //element@attribute filename.xml or foo //element@attribute < filename.xml and return the results line by line? I’m looking for something that would allow me to just apt-get install foo or yum install foo and … Read more

No grammar constraints (DTD or XML schema) detected for the document

I have this dtd : http://fast-code.sourceforge.net/template.dtd But when I include in an xml I get the warning : No grammar constraints (DTD or XML schema) detected for the document. The xml is : <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE templates PUBLIC “//UNKNOWN/” “http://fast-code.sourceforge.net/template.dtd”> <templates> <template type=”INSTANCE_OF_CLASS”> <description>Used to Create instance of class</description> <variation>asasa</variation> <variation-field>asasa</variation-field> <class-pattern>asasa</class-pattern> <getter-setter>setter</getter-setter> <allowed-file-extensions>java</allowed-file-extensions> … Read more

XPath to select Element by attribute value

I have following XML. <?xml version=”1.0″ encoding=”UTF-8″?> <Employees> <Employee id=”3″> <age>40</age> <name>Tom</name> <gender>Male</gender> <role>Manager</role> </Employee> <Employee id=”4″> <age>25</age> <name>Meghna</name> <gender>Female</gender> <role>Manager</role> </Employee> </Employees> I want to select Employee element with id=”4″. I am using below XPath expression which is not returning anything. //Employee/[@id=’4′]/text() I checked it at http://chris.photobooks.com/xml/default.htm and it says invalid xpath, not sure … Read more