Check two attributes : if « XSLT stylesheet « XML Tutorial

XML Tutorial
1. Introduction
2. Namespace
3. XML Schema
4. XPath
5. XSLT stylesheet
Java
XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML Tutorial » XSLT stylesheet » if 
5. 44. 3. Check two attributes
File: Data.xml
<?xml version="1.0" standalone="yes"?>
<poem author="jm" year="1667">
  <verse>line 1</verse>
  <verse>line 2</verse>
  <verse>line 3</verse>
  <verse>line 4</verse>
</poem>

File: Transform.xslt
<?xml version="1.0" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="text" />
  <xsl:template match="poem">
    <xsl:if test="(@author = 'bd') or (@year='1667')">
      Either the author is "bd" or the year is "1667".
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>
Output:


      Either the author is "bd" or the year is "1667".
5. 44. if
5. 44. 1. The Element: Conditional Processing
5. 44. 2. Use if statement to test if an element as an attribute
5. 44. 3. Check two attributes
5. 44. 4. Nested if statement
5. 44. 5. if test="not(preceding-sibling::address[zip=$lastZip])"
5. 44. 6. if test="(position() mod 2) = 1"
5. 44. 7. select with if them else statement
5. 44. 8. xsl:if instruction enables conditional processing
5. 44. 9. Use if statement to check whether it is the last
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.