OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] xsl:if to find the existence of an element

[ Lists Home | Date Index | Thread Index ]

In the template rule for <SendTaxRequest>,

<element name="TaxOutOfCountryFlag" type="ebsidicString" totalDigits="1"
<xsl:attribute name="value">
  <xsl:choose>
  <xsl:when test="TaxOutOfCountryFlag">Y</xsl:when>
  <xsl:otherwise>N</xsl:otherwise>
  </xsl:choose>
</xsl:attribute>
</element>

Or in XSLT 2.0 / XPath 2.0

<element name="TaxOutOfCountryFlag" type="ebsidicString" totalDigits="1"
value="{if (TaxOutOfCountryFlag) then 'Y' else 'N'}"/>

Incidentally, EBCDIC is usually spelt EBCDIC....

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com 

> -----Original Message-----
> From: Vanam, Ravindar [mailto:Ravindar.Vanam@nordstrom.com]
> Sent: 10 April 2002 17:33
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] xsl:if to find the existence of an element
> 
> 
> Hi All,
> 
> Good Morning.
> 
> I am facing a problem in finding a way to solve the following problem.
> 
> Problem Description:
> -----------------------
> I have an optional tag with no value associated in the XML 
> document. Only the existence & non existence of the tag matters
> E.g: 
> <?xml version="1.0" encoding="UTF-8"?>
> <SendTaxRequest>
> 	<TransactionNumber>12345</TransactionNumber>
> 	<BusinessDayDate>20020106</BusinessDayDate>
> 	<TaxOutOfCountryFlag/>
> </SendTaxRequest>
> 
> The Tag "TaxOutOfCountryFlag" is an optional tag.
> 
> The requirement is that I have to transform the above XML 
> document to another XML document considering the existence of 
> the optional field "TaxOutOfCountryFlag". like following..
> 
> 1. If "TaxOutOfCountryFlag" element exists the result should be....
> <?xml version="1.0"?>
> <SendTaxRequest>
> 	<element name="TransactionIdentifier" 
> type="ebsidicString" totalDigits="4" value="TX03"/>
> 	<element name="BusinessDayDate" type="date" 
> totalDigits="8" value="20020106"/>
> 	<element name="TaxOutOfCountryFlag" 
> type="ebsidicString" totalDigits="1" value="Y"/>
> </SendTaxRequest>
> 
> 2. If "TaxOutOfCountryFlag" element does not exist the result 
> should be....
> <?xml version="1.0"?>
> <SendTaxRequest>
> 	<element name="TransactionIdentifier" 
> type="ebsidicString" totalDigits="4" value="TX03"/>
> 	<element name="BusinessDayDate" type="date" 
> totalDigits="8" value="20020106"/>
> 	<element name="TaxOutOfCountryFlag" 
> type="ebsidicString" totalDigits="1" value="N"/>
> </SendTaxRequest>
> 
> Note: the "value" attribute of "TaxOutOfCountryFlag" is changing.
> 
> Please suggest me how can I accomplish this problem. Any help 
> is greatly appreciated.
> 
> Thanks,
> Ravi
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
> 




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS