[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl:if to find the existence of an element


xsl if element name
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

When you've got one flag xslt's fine, for nested logic, use de
Morgan or SAX  ;)

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="SendTaxRequest">
   <SendTaxRequest>
    <xsl:apply-templates/>
    <element name="TaxOutOfCountryFlag" 
       type="ebsidicString" 
       totalDigits="1" 
       value="N">
      <xsl:if test="TaxOutOfCountryFlag">
        <xsl:attribute name="value">Y</xsl:attribute>
      </xsl:if>
    </element>
   </SendTaxRequest>
  </xsl:template>

  <xsl:template match="TransactionNumber">
   <element name="TransactionIdentifier" 
      type="ebsidicString" 
      totalDigits="4" 
      value="TX03"/>
  </xsl:template>

  <xsl:template match="BusinessDayDate">
   <xsl:variable name="foo" select="current()"/>
   <element name="BusinessDayDate" 
     type="ebsidicString" 
     totalDigits="{string-length($foo)}" 
     value="{$foo}"/>
  </xsl:template>
</xsl:stylesheet>


> -----Original Message-----
> From: Phil Fuhlman [mailto:pfuhlman@D...] 
> Sent: 10 April 2002 17:37
> To: xml-dev@l...
> Subject: RE:  xsl:if to find the existence of an element
> 
> 
> With all due respect, and since you asked, IMHO, this may be 
> a good example of where XSL is *maybe* the wrong tool and you 
> may want to consider using a 'real programming language', ie. 
> anything from VBScript, JavaScript, Perl, Python on up to 
> C/C++, Fortran or Cobol.
> 
> "...when the only tool you have is a hammer, all of your 
> problems start to look like nails..."
> 
> But then again, I get this feeling anytime I hear/read "if" 
> and "XML transform" <lol>
> 
> </pff>
> 
> -----Original Message-----
> From: Vanam, Ravindar [mailto:Ravindar.Vanam@n...]
> Sent: Wednesday, April 10, 2002 11:33 AM
> To: xml-dev@l...
> Subject:  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>


- -----------------------------------------------------------------
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>


-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPLSAs+aWiFwg2CH4EQKAQACg9WIO1FuyAW+7u+8MVCY5E98z6RMAmwfU
UQ8/Q98p3OFC2pvuSy0EEU+D
=nZYo
-----END PGP SIGNATURE-----


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.