Pages

Monday, April 11, 2016

Substitutions in Regular Expressions

Use full link on Substitutions in Regular Expressions https://msdn.microsoft.com/en-us/library/ewy2t5e0(v=vs.110).aspx

Wednesday, September 25, 2013

EPUB3 Support Grid

http://www.bisg.org/docs/BISG_EPUB3PlatformGrid.xls

Monday, July 22, 2013

Monkey Testing

The best technique to do XML Conversion testing is Monkey Testing. Create all possible combinations of elements and create the Monkey Source file. Use it as a test data for testing.

Use the below link for creating the combinations

Test Your Regex

Saturday, June 15, 2013

Test Your XSLT here

http://xslttest.appspot.com/

XSLT Functions

Date/Time

current-date

DESCRIPTION

Returns the current date

XML


<?xml version="1.0" encoding="UTF-8"?>
<root>Date</root>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="root">
<h1><xsl:value-of select="current-date()"/></h1>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


2011-12-29+05:30
          

current-dateTime

DESCRIPTION

Returns the current date and time

XML


<?xml version="1.0" encoding="UTF-8"?>
<root>DateTitme</root>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="root">
<html>
<body><h1><xsl:value-of select="current-dateTime()"/></h1></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


2011-12-29T16:50:20.316+05:30
          

current-group

DESCRIPTION

Returns the contents of the current group selected by xsl:for-each-group

XML


<?xml version="1.0" encoding="UTF-8"?>  
<towns>
<town>A</town>
<town>B</town>
<town>C</town>
<town>D</town>
<town>E</town>
<town>F</town>
<town>G</town>
<town>H</town>
<town>I</town>
<town>J</town>
<town>K</town>
<town>L</town>
</towns>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:param name="cols" select="4" />
<xsl:template match="towns">
<html>
<body>
<table>
<xsl:variable name="sorted-towns" as="element()*">
<xsl:perform-sort select="town">
<xsl:sort />
</xsl:perform-sort>
</xsl:variable>
<xsl:for-each-group select="$sorted-towns" group-adjacent="(position()-1) idiv $cols">
<tr>
<xsl:for-each select="current-group()">
<td>
<xsl:value-of select="." />
</td>
</xsl:for-each>
</tr>
</xsl:for-each-group>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


A B C D 
E F G H 
I J K L 
          

current-grouping-key

DESCRIPTION

Returns the value that is the grouping key of the current group selected by xsl:for-each-group

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file name="swablr.eps" size="4313" project="mars"/>
<file name="batboy.wks" size="424"  project="neptune"/>
<file name="potrzebie.dbf" size="1102" project="jupiter"/>
<file name="kwatz.xom" size="43"   project="jupiter"/>
<file name="paisley.doc" size="988"  project="neptune"/>
<file name="ummagumma.zip" size="2441" project="mars"/>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output  method="html" indent="yes"/>
<xsl:template match="files">
<html>
<body>
<xsl:for-each-group select="file" group-by="@project">
<p>
<xsl:value-of select="current-grouping-key()"/>
</p>
</xsl:for-each-group>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


mars

neptune

jupiter
          

current-time

DESCRIPTION

Returns the current time

XML


<?xml version="1.0" encoding="UTF-8"?>
<root>CurrentTitme</root>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes" method="html"/>
<xsl:template match="root">
<html>
<body><h1><xsl:value-of select="current-time()"/></h1></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


16:52:33.151+05:30
          

day-from-date

DESCRIPTION

Extracts the day component of a date value

XML


<?xml version="1.0" encoding="UTF-8"?>
<root>2006-08-15</root>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="day-from-date(xs:date(.))"/></p>
</body>
</html>
</xsl:template>    
</xsl:stylesheet>
          

OUTPUT


15
          

day-from-dateTime

DESCRIPTION

Extracts the day component of a dateTime value

XML


<?xml version="1.0" encoding="UTF-8"?>
<root>2006-08-15T10:30:23</root>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">    
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="day-from-dateTime(xs:dateTime('2006-08-15T10:30:23'))"/></p>
</body>
</html>
</xsl:template>    
</xsl:stylesheet>
          

OUTPUT


15
          

days-from-dayTimeDuration

DESCRIPTION

Extracts the days component of a dayTimeDuration value

XML


<?xml version="1.0" encoding="UTF-8"?>
<root>Sample for DayfromdayTimeDuration</root>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="days-from-duration(xs:dayTimeDuration('P5D'))"></xsl:value-of></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


5
          

format-date

DESCRIPTION

Formats a date

XML


<?xml version="1.0"?>
<f_date>2004-03-31</f_date>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<p>
<xsl:value-of select="format-date(f_date, '[D1] [MNn] [Y1]')" />
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


31 March 2004
          

format-dateTime

DESCRIPTION

Formats a dateTime

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<f_dateTime>formateDate</f_dateTime>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<!-- xslt:format-dateTime -->       
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:variable name="dt" select="current-dateTime()"/>
<p><xsl:value-of select="format-dateTime($dt, '[h].[m01][Pn] on [FNn], [D1o] [MNn]')"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


2011-12-29T17:40:55.962+05:30

5.40p.m. on Thursday, 29th December
          

format-time

DESCRIPTION

Formats a time

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<time>Format Time</time>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="format-time(current-time(),'[h].[m01]')"/></p></body>
</html>
</xsl:template>  
</xsl:stylesheet>
          

OUTPUT


5.46
          

hours-from-dateTime

DESCRIPTION

Extracts the hour component of a dateTime value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<hours>Hours From the date</hours>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="hours-from-dateTime(current-dateTime())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


17
          

hours-from-duration

DESCRIPTION

Extracts the hours component of a dayTimeDuration value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<hour>hours Form Duration</hour>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="hours-from-duration(xs:dayTimeDuration('P1DT5H'))"></xsl:value-of></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


5
          

hours-from-time

DESCRIPTION

Extracts the hours component of a time value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<hour>Hours from time</hour>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="hours-from-time(current-time())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


18
          

Implicit-Timezone

DESCRIPTION

Returns the implicit timezone

XML


<?xml version="1.0"?>
<Implicity>TimeZone</Implicity>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="implicit-timezone()"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


0
          

minutes-from-dateTime

DESCRIPTION

Extracts the minutes component of a dateTime value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<Current>Minutes-fromdateTime</Current>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="minutes-from-dateTime(current-dateTime())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


12
          

minutes-from-duration

DESCRIPTION

Extracts the minutes component of a dayTimeDuration value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<minutes>minutes from duration</minutes>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="minutes-from-duration(xs:dayTimeDuration('PT3H'))"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


0
          

minutes-from-time

DESCRIPTION

Extracts the minutes component of a time value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<min>Min-from-Time</min>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="minutes-from-time(current-time())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


29
          

month-from-date

DESCRIPTION

Extracts the month component of a date value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<min>Min-from-Date</min>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="month-from-date(current-date())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


12
          

month-from-dateTime

DESCRIPTION

Extracts the month component of a dateTime value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<min>Min-from-DateTime</min>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="month-from-dateTime(current-dateTime())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


12
          

months-from-duration

DESCRIPTION

Extracts the months component of a yearMonthDuration value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<month>month from Duration</month>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="months-from-duration(xs:yearMonthDuration('P18M'))"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


6
          

seconds-from-dateTime

DESCRIPTION

Extracts the seconds component of a dateTime value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<seconds>seconds from dataTimes</seconds>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="seconds-from-dateTime(current-dateTime())"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


37.435
          

seconds-from-duration

DESCRIPTION

Extracts the seconds component of a dayTimeDuration value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<seconds>seconds from Duration</seconds>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:pe="http://datypic.com/pre" xmlns:unpre="http://datypic.com/unpre" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="seconds-from-duration(xs:dayTimeDuration('PT90.5S'))"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


30.5
          

seconds-from-time

DESCRIPTION

Extracts the seconds component of a time value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<secondes>seconds-from-time</secondes>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">                      
<html>
<body><p><xsl:value-of select="seconds-from-time(current-time())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


15.752
          

timezone-from-dateTime

DESCRIPTION

Extracts the timezone component of a dateTime value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<timezone>timezonefromdatetime</timezone>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="timezone-from-dateTime(current-dateTime())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


PT0S
          

timezone-from-time

DESCRIPTION

Extracts the timezone component of a time value

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<timezone>timezoneformtime</timezone>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<!-- function-available  -->
<xsl:template match="/">
<html><body><p><xsl:value-of select="timezone-from-time(current-time())"/></p></body></html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


PT5H30M
          

YearFromDate

DESCRIPTION

Extracts the year component of a date value

XML


<?xml version="1.0"?>
<Year>Year-from-Date</Year>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="year-from-date(current-date())"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


2011
          

YearFromDateTime

DESCRIPTION

Extracts the year component of a dateTime value

XML


<?xml version="1.0"?>
<YearFromDateTime>YearFromDateTime</YearFromDateTime>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<html><body><p><xsl:value-of select="year-from-dateTime(current-dateTime())"/></p></body></html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


2011
          

YearsFromYearMonthDuration

DESCRIPTION

Extracts the years component of a yearMonthDuration value

XML


<?xml version="1.0"?>
<YearFromYearMonthDuration>YearFromMonthDuration</YearFromYearMonthDuration>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="years-from-duration(xs:yearMonthDuration('P3Y13M'))"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


4
          

Group Common

data

DESCRIPTION

Returns the result of atomizing the supplied sequence

XML


<?xml version="1.0"?>
<files>
<file name="swablr.eps"     size="4313" project="mars"/>
<file name="batboy.wks"     size="424"  project="neptune"/>
<file name="potrzebie.dbf"  size="1102" project="jupiter"/>
<file name="kwatz.xom"      size="43"   project="jupiter"/>
<file name="paisley.doc"    size="988"  project="neptune"/>
<file name="ummagumma.zip"  size="2441" project="mars"/>
<file name="schtroumpf.txt" size="389"  project="mars"/>
<file name="mondegreen.doc" size="1993" project="neptune"/>
<file name="gadabout.pas"   size="685"  project="jupiter"/>
</files>
          

XSLT


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="files">
<html>
<body>
<xsl:for-each select="file">
<h1><xsl:value-of select="data(@name)"/></h1>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


swablr.eps
batboy.wks
potrzebie.dbf
kwatz.xom
paisley.doc
ummagumma.zip
schtroumpf.txt
mondegreen.doc
gadabout.pas
          

deep-equal

DESCRIPTION

Compares two sequences for deep equality: the names and contents must be the same, but nodes need not have the same identity.

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file name="swablr.eps" size="4313" project="mars"/>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes" method="xhtml"/>
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="deep-equal(1, 1)"/></h1>
<h2><xsl:value-of select="deep-equal(1, 2)"/></h2>
<h3><xsl:value-of select="deep-equal((1, 1), (1, 1))"/></h3>
<h4><xsl:value-of select="deep-equal((1, 1), (1, 2))"/></h4>
<h5><xsl:value-of select="deep-equal((2, 1), (1, 2))"/></h5>
<h6><xsl:value-of select="deep-equal((1, 2), (2, 1))"/></h6>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


true
false
true
false
false
false
          

default-collation

DESCRIPTION

Returns the name of the default collation

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file name="swablr.eps"     size="4313" project="mars"/>
<file name="batboy.wks"     size="424"  project="neptune"/>
<file name="potrzebie.dbf"  size="1102" project="jupiter"/>
<file name="kwatz.xom"      size="43"   project="jupiter"/>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<html>
<body><h1><xsl:value-of select="default-collation()"/></h1></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


http://www.w3.org/2005/xpath-functions/collation/codepoint
          

disable-output-escaping

DESCRIPTION

This attribute may be set on the xsl:attribute element. If set to the value "yes", it causes the value of the attribute to be output "as is", without escaping special characters. For example, this allows a URL value to be output containing an unescaped ampersand, e.g. <a href="http://www.acme.com/buy.asp?product=widget&price=12.95">. This also suppresses the escaping of non-ASCII characters in a URL by %HH sequences.

XML


<?xml version="1.0" encoding="utf-8"?>
<catalog>Disable-output-escaping</catalog>
          

XSLT


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:text disable-output-escaping="yes"><p></xsl:text><xsl:apply-templates/><xsl:text disable-output-escaping="yes"></p></xsl:text>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Disable-output-escaping
          

distinct-values

DESCRIPTION

Returns the set of distinct values present in a given sequence, comparing strings using a named collation.

XML


<?xml version="1.0" encoding="utf-8"?>
<files>
<file project="jupiter">Hi</file>
<file project="jupiter">Hi</file>
<file project="mars">bye</file>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output encoding="UTF-8" method="xhtml" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="files">
<p><xsl:value-of select="distinct-values(file)"/></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Hi Bye
          

element-available

DESCRIPTION

Determines whether a particular instruction (typically, an extension element) is available in the context

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<!--hai-->
<file name="swablr.eps" size="4313" project="mars">Hi</file>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes" method="xhtml"/>
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="element-available('xsl:comment')"/></h1></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


true
          

empty

DESCRIPTION

Returns true if the given sequence is empty

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file>hi</file>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="empty(remove(('ab','cd'), 1))"/></h1>
<h1><xsl:value-of select="empty(remove((), 1))"/></h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


false
true
          

ends-with

DESCRIPTION

Returns true if the first string ends with the second string, when compared using the named collation

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file>xyz</file>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="Ex" select="files/file"/>
<html>
<body>
<h1>
<xsl:value-of select=" ends-with($Ex,'z')"/>
</h1>
<h1>
<xsl:value-of select=" ends-with($Ex,'y')"/>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


true
false
          

escape-uri

DESCRIPTION

Applies the %HH escaping convention to a URI

XML


<?xml version="1.0" encoding="UTF-8"?>
<file>
<file1>http://example.com/test#car</file1>
<file2>http%3A%2F%2Fexample.com%2Ftest#car</file2>
</file>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="uri" select="file/file1"/>
<xsl:variable name="uri1" select="file/file2"/>
<html>
<body>
<h1>
<xsl:value-of select="escape-html-uri($uri)"/>
</h1>
<h1>
<xsl:value-of select="escape-html-uri($uri1)"/>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


http://example.com/test#car
http%3A%2F%2Fexample.com%2Ftest#car
          

exactly-one

DESCRIPTION

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file>Hi Byw</file>
<file>Bye</file>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<body><h1><xsl:value-of select="exactly-one(files/file[2])"/></h1></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Bye
          

exists

DESCRIPTION

Returns true if the given sequence is not empty

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file name="swablr.eps" size="4313" project="mars"/>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="exists((2,3))"/></h1>
<h3><xsl:value-of select="exists(remove(('ab'), 1))"/></h3>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


true
false
          

false

DESCRIPTION

Returns the boolean value false

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file>10</file>
<file>21</file>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h1>
<xsl:value-of select="false() = exists((2,3))"/>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


false
          

floor

DESCRIPTION

Rounds a number towards minus infinity

XML


<?xml version="1.0" encoding="UTF-8"?>
<files>
<file>10.2</file>
<file1>21.3</file1>
</files>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="floor(files/file)"/></h1>
<h2><xsl:value-of select="floor(files/file1)"/></h2>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


10
21
          

ID

DESCRIPTION

Finds the elements with given ID attribute values

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="//persons/person/@id">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
</body>
</html>
</xsl:template> 
</xsl:stylesheet>
          

OUTPUT


1

2

3
          

IndexOf

DESCRIPTION

Finds the positions of items in a sequence that match the second argument, using a named collation for the comparison

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="#all">
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="index-of((15, 40, 34, 40, 10), 40)"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


2 4
          

InsertBefore

DESCRIPTION

Insert an item into a sequence

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="#all">
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="insert-before(('ab', 'cd'), 2, 'gh')"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


ab gh cd
          

Key

DESCRIPTION

Returns the nodes identified by a named key declaration in the stylesheet.

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="#all">
<xsl:key name="preg" match="person" use="@id"/>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="key('preg','3')">
<p>Id: <xsl:value-of select="@id"/></p>
<p>Name: <xsl:value-of select="@name"/></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Id: 3

Name: Dolly
          

Lang

DESCRIPTION

Returns true if the xml:lang value for the context node matches the given language

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">First value</person>
<person name="Donald" id="2">Middle value</person>
<person name="Dolly" id="3">Last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:template match="/">
<html>
<body>
<xsl:if test="lang('en',persons/@xml:lang)">
<xsl:for-each select="persons">
<p>
<xsl:apply-templates select="person[1]"/>
</p>
</xsl:for-each>
</xsl:if>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


First value
          

Last

DESCRIPTION

Returns the context size (the size of the sequence of items currently being processed)

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">Last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="#all">
<xsl:template match="/">
<html>
<body>
<p><xsl:value-of select="//person[last()]"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Last value
          

LocalName

DESCRIPTION

Returns the local part of the name of the context node

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="#all">
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="node()[local-name()='persons']/@xml:lang"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


en
          

LowerCase

DESCRIPTION

Translates characters in a string to lower case

XML


<?xml version="1.0"?>
<persons xml:lang="en">INDIA</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body><p><xsl:value-of select="lower-case(persons)"/></p></body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


INDIA
          

min/max

DESCRIPTION

min: Returns the lowest value in a sequence of comparable items

max: Returns the highest value in a sequence of comparable items

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first value</person>
<person name="Donald" id="2">middle value</person>
<person name="Dolly" id="3">last value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:variable name="a" select="persons/person[1]/@id"/>
<xsl:variable name="b" select="persons/person[2]/@id"/>
<html>
<body>
<p><xsl:value-of select="min(($a,$b))"/></p>
<p><xsl:value-of select="max(($a,$b))"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


1

2
          

name/local-name/namespace-uri

DESCRIPTION

name: Returns the name of the context node, as a string in the lexical form of a QName

local-name: Returns the local part of the name of a given node

namespace-uri: Returns the namespace URI of the name of the context node

XML


<?xml version="1.0"?>
<poem xmlns:red="http://www.java2s.com/red">
<red:verse>line 2</red:verse>
</poem>
          

XSLT


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="*[local-name()='verse']">
<html>
<body>
<p>name: <xsl:value-of select="name()"/></p>
<p>local-name: <xsl:value-of select="local-name()"/></p>
<p>namespace-uri: <xsl:value-of select="namespace-uri()"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


name: red:verse

local-name: verse

namespace-uri: http://www.java2s.com/red
          

NormalizeSpace

DESCRIPTION

Eliminates redundant spaces from the string value of the context node

XML


<?xml version="1.0"?>
<persons xml:lang="en">
<person name="Tarzan" id="1">first             value</person>
<person name="Donald" id="2">middle  value</person>
<person name="Dolly" id="3">last  value</person>
</persons>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="persons/person">
<p><xsl:value-of select="normalize-space(.)"/></p>    
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


first value

middle value

last value
          

normalize-unicode

DESCRIPTION

Converts a string to a given Unicode normalized form by modifying the way in which combining characters are represented

XML


<?xml version="1.0"?> 
<text>leçon</text>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="html"/>
<xsl:template match="text">
<html>
<bdoy><p><xsl:value-of select="normalize-unicode(.)"/></p></bdoy>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


leçon
          

not

DESCRIPTION

Returns true if the effective boolean value of the argument is false, and vice versa

XML


<?xml version="1.0"?> 
<no>5</no>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="no">
<html>
<body>
<p><xsl:value-of select="not((.)=2)"/></p>
<p><xsl:value-of select="not((.)=5)"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


true

false
          

number/output

DESCRIPTION

Converts the string value of the context node to a number

XML


<?xml version="1.0" encoding="UTF-8"?>
<pricelist>
<price currency="USD">69.000</price>
<price currency="USD">68.99</price>
<price currency="USD">9.0</price>
<price currency="USD">Rs.90</price>
</pricelist>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="pricelist/price">
<p><xsl:value-of select="number(.)"/></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


69

68.99

9

NaN
          

position

DESCRIPTION

Returns the context position (that is, the position of the context item in the sequence currenly being processed)

XML


<?xml version="1.0" encoding="UTF-8"?>
<provinces>
<name>Alberta</name>
<name>British Columbia</name>
<name>Manitoba</name>
<name>New Brunswick</name>
<name>Newfoundland and Labrador</name>
</provinces>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="provinces">
<html>
<body>
<xsl:for-each select="name">
<p><xsl:value-of select="position()" /><xsl:text>. </xsl:text><xsl:value-of select="." /></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


1. Alberta

2. British Columbia

3. Manitoba

4. New Brunswick

5. Newfoundland and Labrador
          

remove

DESCRIPTION

Removes the item at a given position in a sequence

XML


<?xml version="1.0"?> 
<text>a, b, c</text>
          

XSLT


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html><bod><p><xsl:value-of select="remove(('a', 'b', 'c'), 2)"/></p></bod></html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


a c
          

current

DESCRIPTION

Returns the item that was the current item supplied on entry to the XPath expression

XML


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<database>
<emp_1>
<designation>DB Administrator</designation> 
</emp_1>
<emp_2>
<designation>Software Engineer</designation> 
</emp_2>
</database>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="database//designation">
<p>Current node: <xsl:value-of select="name()" /></p>
<p>Designation: <xsl:value-of select="current()" /></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Current node: designation

Designation: DB Administrator

Current node: designation

Designation: Software Engineer
          

format-number

DESCRIPTION

Formats a number as specified by a picture string, using the default decimal format

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<database>Example</database>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:value-of select='format-number(500100, "#")' />
<br/>
<xsl:value-of select='format-number(500100, "#.00")' />
<br/>
<xsl:value-of select='format-number(500100, "#.0")' />
<br/>
<xsl:value-of select='format-number(500100, "###,###.00")' />
<br/>
<xsl:value-of select='format-number(0.23456, "#%")' />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


<html>
<body>500100<br>500100.00<br>500100.0<br>500,100.00<br>23%
</body>
</html>
          

generate-id

DESCRIPTION

Returns a generated unique identifier of the context node

XML


<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<emp>
<name>Arun</name>
<age>28</age>
<degree>B.E.</degree>
<exp>
<year>5</year>
<month>3</month>
</exp>
<designation>DB Administrator</designation>
<salary>30000</salary>
</emp>
<emp>
<name>Riqshitha</name>
<age>25</age>
<degree>B.Tech.</degree>
<exp>
<year>2</year>
<month>3</month>
</exp>
<designation>Software Engineer</designation>
<salary>25000</salary>
</emp>
<emp>
<name>Lakshana</name>
<age>20</age>
<degree>B.Arch.</degree>
<exp>
<year>1</year>
<month>3</month>
</exp>
<designation>Architect</designation>
<salary>20000</salary>
</emp>
</database>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Name</h2>
<ul>
<xsl:for-each select="database/emp">
<li>
<a href="#{generate-id(name)}"><xsl:value-of select="name" /></a>
</li>
</xsl:for-each>
</ul>
<xsl:for-each select="database/emp">
Name: <a name="{generate-id(name)}"> <xsl:value-of select="name" /></a>
Age: <xsl:value-of select="age" />
Salary: <xsl:value-of select="salary" />
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


<html>
<body>
<h2>Name</h2>
<ul>
<li><a href="#d1e5">Arun</a></li>
<li><a href="#d1e33">Riqshitha</a></li>
<li><a href="#d1e61">Lakshana</a></li>
</ul>
Name: <a name="d1e5">Arun</a>
Age: 28
Salary: 30000
Name: <a name="d1e33">Riqshitha</a>
Age: 25
Salary: 25000
Name: <a name="d1e61">Lakshana</a>
Age: 20
Salary: 20000
</body>
</html>
          

saxon:assign

DESCRIPTION

The saxon:assign element is used to change the value of a local or global variable that has previously been declared using xsl:variable (or xsl:param). The variable or parameter must be marked as assignable by including the extra attribute saxon:assignable="yes"

XML


<?xml version="1.0" encoding="ISO-8859-1" ?>
<student_list>
<student>
<name>George Washington</name>
<major>Politics</major>
<idsx>10</idsx>
<phone>312-123-4567</phone>
<email>gw@example.edu</email>
</student>
<student>
<name>Janet Jones</name>
<major>Undeclared</major>
<idsx>12</idsx>
<phone>311-122-2233</phone>
<email>janetj@example.edu</email>
</student>
<student>
<name>Joe Taylor</name>
<major>Engineering</major>
<idsx>1</idsx>
<phone>211-111-2333</phone>
<email>joe@example.edu</email>
</student>
</student_list>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon"  version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:for-each select="student_list/student/name">
<xsl:variable name="idx" saxon:assignable="yes" select="1"/>
<xsl:choose>
<xsl:when test="element-available('saxon:while')">
<saxon:while test="$idx < 11">
The value of idx is <xsl:value-of select="$idx"/>
<saxon:assign name="idx" select="$idx+1"/>
</saxon:while>
</xsl:when>
<xsl:otherwise>
Current node: 
Name: <xsl:value-of select="current()" /> 
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


Current node: 
Name: George Washington
Current node: 
Name: Janet Jones
Current node: 
Name: Joe Taylor
          

saxon:doctype

DESCRIPTION

The saxon:doctype instruction is used to insert a document type declaration into the current output file. It must be instantiated before the first element in the output file is written.

XML


<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<emp id="1" doj="10-2-2008">
<name>Arun</name>
<age>28</age>
<degree>B.E.</degree>
<exp>
<year>5</year>
<month>3</month>
</exp>
<designation>DB Administrator</designation>
<salary>30000</salary>
</emp>
<emp id="2" doj="13-9-2011">
<name>Riqshitha</name>
<age>25</age>
<degree>B.Tech.</degree>
<exp>
<year>2</year>
<month>3</month>
</exp>
<designation>Software Engineer</designation>
<salary>25000</salary>
</emp>
<emp id="3" doj="20-2-2010">
<name>Lakshana</name>
<age>20</age>
<degree>B.Arch.</degree>
<exp>
<year>1</year>
<month>3</month>
</exp>
<designation>Architect</designation>
<salary>20000</salary>
</emp>
<emp id="4" doj="16-11-2006">
<name>Mithra</name>
<age>20</age>
<degree>B.E.</degree>
<exp>
<year>3</year>
<month>3</month>
</exp>
<designation>Architect</designation>
<salary>20000</salary>
</emp>
</database>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://www.jclark.com/xt/java/java.util.Date" xmlns:saxon="http://saxon.sf.net/" xmlns:ext="http://www.bryantcs.com/xsl/extensions" extension-element-prefixes="saxon">
<xsl:template match="/">
<saxon:doctype xsl:extension-element-prefixes="saxon">
<dtd:doctype name="Employee Database" xmlns:dtd="http://saxon.sf.net/dtd" xsl:exclude-result-prefixes="dtd">
<dtd:element name="Example" content="(emp)*"/>
<dtd:element name="emp" content="(designation|salary)"/>
<dtd:attlist element="emp">
<dtd:attribute name="id" type="ID" value="#REQUIRED"/>
<dtd:attribute name="doj" type="CDATA" value="#IMPLIED"/>
</dtd:attlist>
<dtd:element name="designation" content="(#PCDATA)"/>
<dtd:element name="salary" content="(#PCDATA)"/>
<dtd:entity name="blurb">'Sample File'</dtd:entity>
</dtd:doctype>
</saxon:doctype>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Employee Database  [
<!ELEMENT Exampl (emp)*>
<!ELEMENT emp (designation|salary)>
<!ATTLIST emp 
id ID #REQUIRED
doj CDATA #IMPLIED>
<!ELEMENT designation (#PCDATA)>
<!ELEMENT salary (#PCDATA)>
<!ENTITY blurb 'Sample File'>
]>
          

saxon:while

DESCRIPTION

The saxon:while element is used to iterate while some condition is true.

XML


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<student_list>Assign and entity-ref</student_list>
          

XSLT


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/" extension-element-prefixes="saxon">
<xsl:output indent="yes" method="xml"/>
<xsl:variable name="i" select="0" saxon:assignable="yes"/>
<xsl:template match="/">
<html>
<body>
<saxon:while test="$i < 10">
<p>The value of i is <saxon:entity-ref name="nbsp"/><xsl:value-of select="$i"/></p>
<xsl:fallback>
<xsl:message>Your XSLT processor doesn't support saxon:while.</xsl:message>
</xsl:fallback>
<saxon:assign name="i" select="$i+1"/>
</saxon:while>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


The value of i is  0

The value of i is  1

The value of i is  2

The value of i is  3

The value of i is  4

The value of i is  5

The value of i is  6

The value of i is  7

The value of i is  8

The value of i is  9
          

system-property

DESCRIPTION

Returns the value of a system property

XML


<?xml version="1.0" encoding="ISO-8859-1"?>
<database>
<emp>
<name>Arun</name>
<age>28</age>
<degree>B.E.</degree>
<exp>
<year>5</year>
<month>3</month>
</exp>
<designation>DB Administrator</designation>
<salary>30000</salary>
</emp>
<emp>
<name>Riqshitha</name>
<age>25</age>
<degree>B.Tech.</degree>
<exp>
<year>2</year>
<month>3</month>
</exp>
<designation>Software Engineer</designation>
<salary>25000</salary>
</emp>
<emp>
<name>Lakshana</name>
<age>20</age>
<degree>B.Arch.</degree>
<exp>
<year>1</year>
<month>3</month>
</exp>
<designation>Architect</designation>
<salary>20000</salary>
</emp>
</database>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<p>
Version:
<xsl:value-of select="system-property('xsl:version')" />
Vendor:
<xsl:value-of select="system-property('xsl:vendor')" />
Vendor URL:
<xsl:value-of select="system-property('xsl:vendor-url')" />
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


<html>
<body>
<p>
Version:
2.0
Vendor:
SAXON 9.1.0.2 from Saxonica
Vendor URL:
http://www.saxonica.com/
</p>
</body>
</html>
          

Group Document

doc

DESCRIPTION

Loads a document identified by its URI

XML


<files>
<file name="swablr.eps"     size="4313" project="mars"/>
<file name="batboy.wks"     size="424"  project="neptune"/>
<file name="potrzebie.dbf"  size="1102" project="jupiter"/>
<file name="kwatz.xom"      size="43"   project="jupiter"/>
<file name="paisley.doc"    size="988"  project="neptune"/>
<file name="ummagumma.zip"  size="2441" project="mars"/>
<file name="schtroumpf.txt" size="389"  project="mars"/>
<file name="mondegreen.doc" size="1993" project="neptune"/>
<file name="gadabout.pas"   size="685"  project="jupiter"/>
</files>

XSLT


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<table>
<xsl:for-each select="doc('myxml.xml')/files/file">
<tr><td><xsl:value-of select="./@name"/></td><td><xsl:value-of select="./@project"/></td><td><xsl:value-of select="./@size"/></td></tr>        
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

OUTPUT


swablr.eps      mars    4313 
batboy.wks      neptune 424 
potrzebie.dbf   jupiter 1102 
kwatz.xom       jupiter 43 
paisley.doc     neptune 988 
ummagumma.zip   mars    2441 
schtroumpf.txt  mars    389 
mondegreen.doc  neptune 1993 
gadabout.pas    jupiter 685 

document-uri

DESCRIPTION

Returns the URI of a document

XML


<files>
<file name="swablr.eps"     size="4313" project="mars"/>
<file name="batboy.wks"     size="424"  project="neptune"/>
<file name="potrzebie.dbf"  size="1102" project="jupiter"/>
<file name="kwatz.xom"      size="43"   project="jupiter"/>
<file name="paisley.doc"    size="988"  project="neptune"/>
<file name="ummagumma.zip"  size="2441" project="mars"/>
<file name="schtroumpf.txt" size="389"  project="mars"/>
<file name="mondegreen.doc" size="1993" project="neptune"/>
<file name="gadabout.pas"   size="685"  project="jupiter"/>
</files>

XSLT


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:variable name="abc" select="doc('D:/arul/xsl_sample/xsl_sample/doc/myxml.xml')"/>
<h1>
<xsl:value-of select="document-uri($abc)"/>
</h1>
</xsl:template>
</xsl:stylesheet>

OUTPUT


D:/arul/xsl_sample/xsl_sample/doc/myxml.xml
     

document

DESCRIPTION

Loads one or more documents identified by their URIs, using the base URI of the node given in the second argument to resolve any relative URIs

XML


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<groups>
<title>Report</title>
<groupRef po="doc_in1.xml"/>
<groupRef href="doc_in2.xml"/>
</groups>


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<database>
<emp_1>
<name>Arun</name> 
<age>28</age> 
<degree>B.E.</degree> 
<exp>
<year>5</year>
<month>3</month>
</exp> 
<designation>DB Administrator</designation> 
<salary>25000</salary> 
</emp_1>
</database>
          

XSLT


<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<title>Report:
<xsl:apply-templates select="/groups/groupRef"/>
</title>
</xsl:template>
<xsl:template match="groups/groupRef">
<xsl:copy-of select="document(@po)//database"/>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


<?xml version="1.0" encoding="UTF-8"?>
<title>Report:
<database>
<emp_1>
<name>Arun</name> 
<age>28</age> 
<degree>B.E.</degree> 
<exp>
<year>5</year>
<month>3</month>
</exp> 
<designation>DB Administrator</designation> 
<salary>25000</salary> 
</emp_1>
</database>
</title>
          

Group Regex

regex-group/matches

DESCRIPTION

Returns the contents of the substring that matched the n'th subexpression in a regular expression processed using xsl:analyze-string

Returns true if the given string matches the given regular expression

XML


<?xml version="1.0" encoding="utf-8"?>
<phonelist>
<phonenumber>111-111-1111</phonenumber>
<phonenumber>(111) 111-1111</phonenumber>
<phonenumber>111.111.1111</phonenumber>
<phonenumber>111-111-112</phonenumber>
<phonenumber>+11 111-1111</phonenumber>
</phonelist>
          

XSLT


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="phonelist/phonenumber">
<xsl:analyze-string select="." regex="([0-9]{{3}})-(\p{{Nd}}{{3}})-([0-9]{{4}})">
<xsl:matching-substring>
<p><xsl:text>
+1 (</xsl:text><xsl:value-of select="regex-group(1)"/><xsl:text>) </xsl:text><xsl:value-of select="regex-group(2)"/><xsl:text>-</xsl:text><xsl:value-of select="regex-group(3)"/></p>
</xsl:matching-substring>
<xsl:non-matching-substring>
<p>Not Valid Number</p>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
          

OUTPUT


+1 (111) 111-1111 

Not Valid Number

Not Valid Number

Not Valid Number

Not Valid Number
          

Links:

http://saxon.sourceforge.net/saxon6.5.3/extensions.html

http://saxon.sourceforge.net/saxon7.9/functions.html