Some tests of the "instance of" operator : instance of « XSLT stylesheet « XML

XML
1. CSS Style
2. SVG
3. XML Schema
4. XQuery
5. XSLT stylesheet
Java
XML Tutorial
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 » XSLT stylesheet » instance of 
Some tests of the "instance of" operator



File: Data.xml


File: Transform.xslt

<?xml version="1.0"?>
<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:text>&#xA;Some tests of the "instance of" operator:</xsl:text>

    <xsl:text>&#xA;&#xA;  '1995-04-21' instance of xs:date: </xsl:text>
    <xsl:value-of select="'1995-04-21' instance of xs:date"/>
    <xsl:text>&#xA;  xs:date('1995-04-21') instance of xs:date: </xsl:text>
    <xsl:value-of select="xs:date('1995-04-21') instance of xs:date"/>
    <xsl:text>&#xA;&#xA;  instance of xs:integer: </xsl:text>
    <xsl:value-of select="3 instance of xs:integer"/>
    <xsl:text>&#xA;  '3' instance of xs:integer: </xsl:text>
    <xsl:value-of select="'3' instance of xs:integer"/>
    <xsl:text>&#xA;  number('3'instance of xs:integer: </xsl:text>
    <xsl:value-of select="number('3') instance of xs:integer"/>
    <xsl:text>&#xA;  number('3'instance of xs:double: </xsl:text>
    <xsl:value-of select="number('3') instance of xs:double"/>
    <xsl:text>&#xA;  xs:integer('3'instance of xs:integer: </xsl:text>
    <xsl:value-of select="xs:integer('3') instance of xs:integer"/>
    <xsl:text>&#xA;  '3' cast as xs:integer instance of xs:integer: </xsl:text>
    <xsl:value-of select="'3' cast as xs:integer instance of xs:integer"/>
    <xsl:text>&#xA;  'e' instance of xs:integer: </xsl:text>
    <xsl:value-of select="'e' instance of xs:integer"/>

  </xsl:template>
</xsl:stylesheet>

Output:


Some tests of the "instance of" operator:

  '1995-04-21' instance of xs:date: false
  xs:date('1995-04-21') instance of xs:date: true

  instance of xs:integer: true
  '3' instance of xs:integer: false
  number('3'instance of xs:integer: false
  number('3'instance of xs:doubletrue
  xs:integer('3'instance of xs:integer: true
  '3' cast as xs:integer instance of xs:integer: true
  'e' instance of xs:integer: false

 
Related examples in the same category
1. instance of element()
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.