[thelist] xsl:if query (xml newbie)

Steve Lewis nepolon at worlddomination.net
Fri Dec 5 17:56:40 CST 2003

I know this is way late, but I am still catching up.

John Dobson has the right technique for checking the existance/absense 
of a node in his <xsl:if />  I did have one thought with regards to 
format.  Consider noting the unit in the XML but not storing the actual 
symbology in the text node.  This has the advantage if recording more 
information in the XML record, without tying you to any particular 
representations.  It cannot hurt to keep the extra information in the 
XML, even if you only use one when condition and your otherwise 
condition is empty.

  <salary @unit="UK/pound"/>9.95</salary>

Then in your xsl transformation you can try something like the following:

  <xsl:when test="person/salary/@unit = 'UK/pound'">
    <xsl:value-of select="person/salary"/>
  <xsl:when test="person/salary/@unit = 'CA/dollar'">
    <xsl:value-of select="person/salary"/>  
    <xsl:text>N/A Slave Labor</xsl:text>


John.Bedard at ngc.com wrote:

><xsl:variable name="salary" select="/person/salary" /> 
>    <xsl:if test="$salary != ''">
>	<xsl:text>£</xsl:text>      
>	<xsl:value-of select="/person/salary"/>
>    </xsl:if>
>Just throwing £ in there does make it through FOP. I threw it into a document I'm working on. I suppose if you want to thorough find the unicode for the character.
>-----Original Message-----
>From: John Dobson [mailto:j.dobson at find-a-part.com]
>Sent: Friday, November 21, 2003 8:19 AM
>To: Thelist (E-mail)
>Subject: [thelist] xsl:if query (xml newbie)
>If you have
>in which salary is either empty of not
><xsl:if test="person/salary">
>£<xsl:value-of select="person/salary" />
>the right way to check if it is empty or not, and then provide the salary with the £ sign in front?

More information about the thelist mailing list