This page contains information and examples of structuring XML documents using XSLT with XPATH
|
Table of Contents
|
XPATH 1.0
W3C Recommendation
Resources
XPath Sandbox:http://www.orbeon.com/ops/sandbox-transformations/xpath/
HTML tidy: http://tidy.sourceforge.net
Firefox addon: hhtps://adddons.mozilla.org/firefox/1095/
/axis-name::node-test[predicate] - numerical [n] or boolean predicate —>
returns sequence (n1,n2)
Get node-set of all 1km records in Great Britain
/dataset/records/spatialreference[@precision=1000][@projection='OSGB']
nodes (prefix:localpart) = document, element, attribute, text, namespace, comment, processing instruction
Axes
| ancestor | parent node upwards to root node |
| ancestor-or-self | context node and parent node upwards to root node |
| attribute (@) | all attributes of contect node |
| child () | direct children of context node |
| descendant (//) | child nodes including children's children etc |
| descendant-or-self | context node and child nodes including children's children etc |
| following | all nodes occurring after context node |
| following-sibling | all siblings occuring after context node |
| namespace | all namespace nodes in scope on context node |
| parent (..) | parent node of context node |
| preceding | all nodes occuring before context node |
| preceding-sibling | all siblings occurring before context node |
| self (.) | context node |
XPATH 2.0
W3C Recommendation
http://www.w3.org/tr/xpath20/
requirements: http://www.w3.org/TR/xpath20req
semantics: http://www.w3.org/TR/xquery-semantics/
data model: http://www.w3.org/TR/xpath-datamodel/
functions: http://www.w3.org/TR/xpath-functions/
Functions
for construct
for $d in /XPATH/NODE return avg($d/NODE)
nested comments
Regular expressions
Union operator
Sequence operator
Additional Functions
- round
- concat | string-join
- lower-case | upper-case
- substring | replace
- year-from-date | month-from-date | day-from-date
XSLT 1.0
W3C Recommendation
Resources
Saxon - http://saxon.sourceforge.net
Stylesheet
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:data='http://www.data.org/example'
xmlns:msxml='http://www.msxml.org'
xmlns:ext='http://www.example.com/XSLT/extensions'
version='1.0'
exclude-result-prefixes='data'
exclude-element-prefixes='ext'>
<xsl:output method='text/html/xml' media-type='text/html' encoding='ISO-8850-1' indent='yes' cdata-section-elements='ELEMENT(S)' />
<-- External data -->
<data:ELEMENT xmlns=''>
<-- data here as xml -->
</data:ELEMENT>
<-- External stylesheets -->
<xsl:include href='PATH.xsl' />
<xsl:import href='PATH.xsl' />
<-- define own extension -->
<msxml:script implements-prefix='ext' language='javascript'>
<![CDATA[
function NAME(nodeSet) {
}
]]>
</msxml:script>
<-- Global parameter and variables -->
<xsl:param name='NAME' select="XPATH|'VALUE'" />
<xsl:variable name='NAME' select="XPATH|'VALUE'" />
<xsl:variable name='RTFNAME'>
<-- Result tree fragment -->
<a href='PATH'>TEXT</a>
</xsl:variable>
<-- Attribute set -->
<xsl:attribute-set name='ATTNAME'>
<xsl:attribute name='NAME'>VALUE</xsl:attribute />
<xsl:attribute name='NAME'>VALUE</xsl:attribute />
</xsl:attribute-set>
<-- Keys -->
<xsl:key name='KEYNAME' match='ELEMENT' use='CHILDELEMENT|ATTRIBUTE />
<-- Handle whitespace -->
<xsl:strip-space elements='*|ELEMENT(S)' />
<xsl:preserve-space elements='*|ELEMENT(S)' />
<-- match to document element -->
<xsl:template match='/'>
<-- Apply template -->
<xsl:apply-templates select='/XPATH/NODE' mode='NAME'>
<xsl:with-param name='NAME'>
<xsl:sort select='XPATH/NODE' data-type='number|text' order='descending' />
</xsl:apply-templates>
<-- Call named template -->
<xsl:call-template name='NAME'>
<xsl:with-param name='NAME' select="XPATH|'VALUE'" />
</xsl:call-templates
<-- Insert nodes to result tree -->
<xsl:processing-instruction name='xml-stylesheet'>
<xsl:text>type='text/css' href='STYLESHEET.css'</xsl:text>
</xsl:processing-instruction>
<xsl:comment>COMMENT</xsl:comment>
<LITERALELEMENT></LITERALELEMENT>
<xsl:element name='NAME' xml:space='preserve'>VALUE</xsl:element>
<xsl:element name='{$PREFIX}:{$NAME}' namespace='{$NAMESPACEURI}>VALUE</xsl:element>
<xsl:text>
</xsl:text> <-- line break -->
<xsl:text>	</xsl:text> <-- tab -->
<xsl:text></xsl:text> <-- space -->
<xsl:text>
</xsl:text> <-- carriage return -->
<xsl:copy-of select='XPATH|NODE' />
<xsl:copy>
<xsl:apply-templates select='@*|node()' />
</xsl:copy>
<-- Attribute value template -->
<xsl:element name='{@ATTRIBUTE}'>VALUE</xsl:element>
<-- Insert result tree fragment -->
<xsl:copy-of select='$RTFNAME' />
<-- Use attribute set -->
<xsl:element name='NAME' xsl:use-attribute-sets='ATTNAME(S)'>
<xsl:attribute name='NAME'>XPATH|VALUE<xsl:attribute />
</xsl:element>
<-- Use keys -->
<xsl:key('KEYNAME', "ELEMENT', use='@ATTRIBUTE'") />
<xsl:for-each select='document('NAME.xml')>
<xsl:value-of select='key('KEYNAME',ATTRIBUTEVALUE') />
<xsl:for-each>
<xsl:variable name ='NAME' select="concat(generate-id(), 'ELEMENT')" />
<-- external documents -->
document(file:///C:/PATH/NAME.xml)/XPATH
document('')/xsl:stylesheet/data:ELEMENT
<xsl:copy-of select="document('PATH.xml')" />
<xsl:variable name='NAME' select="document('PATH.xml', /)" /> <-- get nodeset -->
<-- extensions -->
<xsl:if test="function-available('msxml:FUNCTION')">
<xsl:value-of select='msxmls:FUNCTION(XPATH|NODE)" />
</xsl:if>
<ext:ELEMENT select='XPATH|NODE' by='NODE'>
<xsl:if test="element-available('xsl:for-each group')">
<xsl:for-each-group select='NODE'>
<xsl:value-of select='.' />
</xsl:if>
<xsl:fallback>
<xsl:message terminate='yes'>ERROR MESSAGE</xsl:message>
</xsl:fallback>
</ext:ELEMENT>
</xsl:template>
<-- templates - XPath -->
<xsl:template match='NODE'>
<xsl:value-of select='.' />
<xsl:value-of select='*' />
<xsl:value-of select='name()' />
<xsl:value-of select='namespace-uri(PREFIX:ELEMENT)' />
<xsl:value-of select='local-name(PREFIX:ELEMENT)' />
<xsl:value-of select='node()' />
<xsl:value-of select='text()' />
<xsl:value-of select='comment()' />
<xsl:value-of select='processing-instruction()' />
<xsl:value-of select='parent::ELEMENT//following-sibling::ELEMENT[1]/ELEMENT' />
<xsl:value-of select='../NODE' />
<xsl:value-of select='XPATH//ELEMENT' /> <-- match at all levels -->
<xsl:value-of select='ELEMENT|ELEMENT|ELEMENT' /> <-- concatenates elements -->
<xsl:value-of select="not(XPATH/node='VALUE')" />
<xsl:value-of select="string(NODE)" />
<xsl:value-of select="starts-with(XPATH/node, 'VALUE')" />
<xsl:value-of select="contains(XPATH/node, 'VALUE')" />
<xsl:value-of select="string(NODE) and string(NODE)" />
<xsl:value-of select="string(NODE) or string(NODE)" />
<xsl:value-of select="NODE[@ATTRIBUTE='VALUE']" />
<xsl:value-of select="NODE[starts-with(CHILD, 'VALUE')]" />
<xsl:value-of select="count(XPATH/NODE[starts-with(CHILD, 'VALUE')])" />
<xsl:value-of select="sum(XPATH/NODE[starts-with(CHILD, 'VALUE')])" />
<xsl:value-of select="XPATH/NODE[last()]" />
<xsl:value-of select="XPATH/NODE[1]" />
<xsl:value-of select="XPATH/NODE[position()=1]" />
<xsl:value-of select='normalize-space(XPATH/NODE)' />
substring-before(XPATH/node|'VALUE', 'DELIMITER')
substring-after(XPATH/node|'VALUE', 'DELIMITER')
substring(XPATH/node|'VALUE',1STCHAR,NO.CHAR)
substring($STRING, string-length($string))
concat($STRING,'VALUE',$STRING)
translate(XPATH/node|'VALUE','
','') <-- remove line breaks -->
translate(XPATH/node|'VALUE','abcdefghijklmnopqrstuvwxyz,'ABCDEFGHIJKLMNOPQRSTUVWXYZ') <-- to uppercase -->
number('VALUE') <-- convert to number -->
mod(($NUMBER * 60) + $NUMBER div $NUMBER)
floor($NUMBER)
ceiling($NUMBER)
round($NUMBER)
format-number($DECIMALNUMBER, '0.##')
<xsl:decimal-format name='NAME', decimal-separator=',' grouping-separator=' ', infinity='Infinité' />
</xsl:template>
<xsl:template match='text()'>
<xsl:value-of select='.' />
</xsl:template>
<-- templates - conditions -->
<xsl:template match='NODE' mode ='NAME' priority='1' >
<xsl:/value-of select='XPATH/NODE' disable-output-escaping='yes' />
<xsl:if test='position()!=last()'>,</xsl:if> <-- comma delimited -->
<xsl:choose>
<xsl:when test='XPATH/NODE=VALUE'>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
<xsl:choose>
<xsl:for-each select='XPATH/NODE'>
<xsl:sort order='ascending' />
</xsl:for-each>
</xsl:template>
<-- templates - numbering -->
<xsl:template match='XPATH|NODE' | 'XPATH|NODE' >
<xsl:number format='I'/>
<xsl:number count='node()' />
<xsl:number grouping-size='2' grouping-separator= ' ' />
<xsl:number level='any' from='XPATH|ELEMENT' />
<xsl:number level='multiple' count='XPATH|ELEMENT' format='1-1.A' />
<xsl:value-of select='position()' />
<xsl:value-of select='count(preceding-sibling::NAME) + 100 />
<xsl:value-of select='.' />
<xsl:/template>
<-- templates - examples -->
<xsl:template match='XPATH|NODE'>
<a href='{.}.html'>
<xsl:value-of select='.' />
</a>
<xsl:template>
<xsl:template match='XPATH|NODE'>
<span class='NAME'>
<xsl:apply-templates />
</span>
<xsl:template>
<-- named template -->
<xsl:template name='NAME'>
<xsl:with param name='NAME' />
$NAME
</xsl:template>
<-- recursion template -->
<xsl:template name='NAME'>
<xsl:param name='NAME' select='DEFAULTVALUE' />
<xsl:if test='$NAME > DEFAULTVALUE'>
<xsl:call-template name='NAME'>
<xsl:with-param name='NAME' select='$NAME - 1' />
</xsl:call-template>
</xsl:if>
</xsl:template>
<-- recursion template example -->
<xsl:template name='tokenize'>
<xsl:param name='string' />
<xsl:param name='delimiter' select="' '" />
<xsl:choose>
<xsl:when test='$delimiter and contains($string, $delimiter)'>
<token>
<xsl:value-of select='substring-before($string, $delimiter)' />
</token>
<xsl:call-temlate name='tokenize'>
<xsl:with-param name='string' select='substring-after($string, $delimiter)' />
<xsl:with-param name='delimiter' select='$delimiter' />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<token><xsl:value-of select='$string' /></token>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Examples
This XSL transforms latest updates XML for NBN forum
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head />
<body>
<p>[b][u]GATEWAY UPDATE[/u][/b]</p>
<!-- Gateway summary -->
<xsl:apply-templates select='gatewayupdate/summary' />
<p>[i]Database last updated [b]<xsl:value-of select='gatewayupdate/summary/@lastupdate' />[/b]<br />
Species dictionary publication date [b]<xsl:value-of select='gatewayupdate/dictionary/@publicationdate' />[/b][/i]</p>
<!-- New species datasets -->
<xsl:if test="gatewayupdate/species/new" >
<p>[b][u]<xsl:value-of select='count(gatewayupdate/species/new/organisation/dataset)' /> new species datasets from <xsl:value-of select='count(gatewayupdate/species/new/organisation)' /> organisations[/u][/b]</p>
<xsl:apply-templates select='gatewayupdate/species/new' />
</xsl:if>
<!-- Updated species datasets -->
<xsl:if test="gatewayupdate/species/updated" >
<p>[b][u]<xsl:value-of select='count(gatewayupdate/species/updated/organisation/dataset)' /> updated species datasets from <xsl:value-of select='count(gatewayupdate/species/updated/organisation)' /> organisations[/u][/b]</p>
<xsl:apply-templates select='gatewayupdate/species/updated' />
</xsl:if>
Best wishes<br /><br />
Graham French<br />
NBN Technical Liaison Officer
</body>
</html>
</xsl:template>
<xsl:template match="summary">
<p>[i]There are currently [b]<xsl:value-of select='@taxonrecords' />[/b] species records available on the NBN Gateway from [b]<xsl:value-of select='@taxondatasets' />[/b] different datasets.[/i]</p>
</xsl:template>
<xsl:template match="new">
<xsl:for-each select='organisation'>
[b]<xsl:value-of select='organisationname' />[/b]<br />
<xsl:for-each select='dataset'>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="dataseturl" />
</xsl:attribute>
<xsl:value-of select='datasettitle' /><br />
</xsl:element>
</xsl:for-each>
<br />
</xsl:for-each>
</xsl:template>
<xsl:template match="updated">
<xsl:for-each select='organisation'>
[b]<xsl:value-of select='organisationname' />[/b]<br />
<xsl:for-each select='dataset'>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="dataseturl" />
</xsl:attribute>
<xsl:value-of select='datasettitle' /><br />
</xsl:element>
</xsl:for-each>
<br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This XSL transforms MapMate tetrad records
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:output method="html"/>
<xsl:variable name='Status' select="'Not recorded'" />
<xsl:variable name='Quantity' select='0' />
<xsl:template match="/">
<html>
<head />
<body>
<table>
<tr align='left'>
<td width='150'><b>Tetrad: </b><xsl:value-of select='dataroot/tetradrecords/Gridref' /></td>
<td><b>Site: </b><xsl:value-of select='dataroot/tetradrecords/Site' /> (VC<xsl:value-of select='dataroot/tetradrecords/Vice_x0020_County' />) </td>
</tr>
<tr align='left'>
<td width='150'><b>Date: </b><xsl:value-of select='dataroot/tetradrecords/Date' /></td>
<td><b>Recorder: </b><xsl:value-of select='dataroot/tetradrecords/Recorder' /></td>
</tr>
<tr align='left'>
<td width='150'><b>Species: </b><xsl:value-of select='count(dataroot/tetradrecords/Taxon)' /></td>
<td />
</tr>
</table>
<hr />
<xsl:apply-templates select='dataroot/tetradrecords' mode='tetrad' >
<xsl:sort select='Taxon'/>
</xsl:apply-templates>
<hr />
<b>Accurate grid references</b><br />
<xsl:apply-templates select='dataroot/tetradrecords' mode='accurate' >
<xsl:sort select='Taxon'/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="tetradrecords" mode='tetrad'>
<table>
<xsl:if test='string-length(Gridref) < 6' >
<xsl:choose>
<xsl:when test="Status = $Status">
<tr align='left'>
<td width='45'><xsl:value-of select='Code' /></td>
<td><i><xsl:value-of select='Taxon' /></i></td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr align='l'>
<td width='45'><xsl:value-of select='Code' /></td>
<td><i><xsl:value-of select='Taxon' /></i> (<xsl:value-of select='Status' />)</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</table>
</xsl:template>
<xsl:template match="tetradrecords" mode='accurate'>
<table>
<xsl:if test='string-length(Gridref) > 5' >
<tr align='left'>
<td width='45'><xsl:value-of select='Code' /></td>
<td><i><xsl:value-of select='Taxon' /></i> (<xsl:value-of select='Gridref' />).
<xsl:choose>
<xsl:when test="Quantity = $Quantity">
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='Quantity' /> plant(s).
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select='Comment' />
</td>
</tr>
</xsl:if>
</table>
</xsl:template>
</xsl:stylesheet>
XSLT 2.0
W3C Recommendation
XPATH 2.0 functions
for-each group
<xsl:for-each-group select='XPATH/NODE1'
group-by='XPATH/NODE2'>
<xsl:sort select='XPATH/NODE2' data-type='text' />
<xsl:value-of select='XPATH/NODE2' />
<xsl:for-each select='current-group()'>
<xsl:sort select='NODE3' data-type='text' />
<xsl:value-of select='NODE3' />
</xsl:for-each>
</xsl for-each-group>
Output multiple documents
<xsl:output method='text' name='OUTPUT1' />
<xsl:for-each-group select='XPATH/NODE' group-by='XPATH/NODE2'
<xsl:sort select='XPATH/NODE2' data-type='text'/>
<xsl:variable name='uri' select='concat('XPATH/NODE2', '.txt')' />
<xsl:result-document href='{$uri}' format='OUTPUT1'>
</xsl:result-document>
</xsl:for-each-group>
User-defined functions
<xsl:stylesheet xmlsns:fun='http://www.functionexample.com'>
<xsl:template match='XPATH/NODE)>
<xsl:value=of select='fun:FUNCTIONNAME(XPATH/NODE)/>
</xsl:template>
<xsl:function name='fun:FUNCTIONNAME ' as='xsl:DATATYPE'>
<xsl:param name='NAME' as='xsl:DATATYPE'/>
<xsl:sequence select= <!-- FUNCTION --> />
</xsl:function>
</xsl:stylesheet>
Output XHTML
<xsl:output method='xhtml'
doctype-system='http://ww.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd'
doctype-public=''//W3C/DTD XHTML 1.0 Transitional//EN' version='1.0'
indent='yes' encoding='UTF-16'/>
XSL-FO
W3C Recommendation
Resources
Antenna House Formatter: http://www.antennahouse.com
XSmiles: http://www.xsmiles.org
<?xml version='1.0'?>
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:fo='http://www.w3.org/1999/XSL/Format'>
<xsl:template match='/'>
<fo:root xmlns:fo='http://www.w3.org/1999/XSL/Format'>
<fo:layout-master-set>
<fo:simple-page-master
master-name='MASTERNAME'
page-height='VALUE cm'
page-width='VALUE cm'
margin-top='VALUE cm'
margin-bottom='VALUE cm'
margin-left='VALUE cm'
margin-right='VALUE cm'
reference-orientation='DEGREES'
writing-mode='lr|tb'>
<fo:region-before extent='VALUE cm' />
<fo:region-body margin='VALUE cm' />
<fo:region-after extent= 'VALUE cm' />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference='MASTERNAME'>
<fo:flow flow-name='xsl-region-body|xsl-region-before|xsl_region-after|xsl-region-start|xsl-region-end'>
<fo:block font-size='12pt' font-weight='bold|bolder|lighter' font-family='Ariel' font-style='italic|oblique|normal|backslant|inherit'>TEXT</fo:block>
<xsl:apply-templates select='/XPATH/ELEMENT1' />
</fo:flow>
<!-- LIST -->
<fo:flow flow-name='REGION'>
<fo:list-block provisional-distance-between-starts='VALUE cm'>
<xsl:apply-templates select='/XPATH/ELEMENT2' />
</fo:list-block>
</fo:flow>
<!-- TABLE -->
<fo:flow flow-name='REGION'>
<fo:table table-omit-header-at-break='true' table-omit-footer-at-break='true'>
<fo:table-column column-width='VALUE cm' />
<fo:table-column column-width='VALUE cm' />
<fo:table-column column-width='VALUE cm' />
<fo:table-header>
<fo:table-row text-align='left|right|center' width='VALUE cm'>
<fo:table-cell number-columns-spanned='3' border-left-style='solid' border-right-style='solid' padding='1px' width='100%'>
<fo:block>
<fo:external-graphic src='PATH.png' content-height='VALUE cm'/>
</fo:block>
<fo:table-cell>
</fo:table-row>
</fo:table-row>
<fo:table-row background-color='COLOUR'>
<fo:table-cell border-style='solid' padding-top='1px' padding-bottom='1px' padding-left='1px' padding-right='1px'>
<fo:block>HEADING1</fo:block>
<fo:table-cell>
<fo:table-cell border-style='solid' padding-top='1px' padding-bottom='1px' padding-left='1px' padding-right='1px'>
<fo:block>HEADING2</fo:block>
<fo:table-cell>
</fo:table-header>
<fo:table-body>
</fo:table-row>
<xsl:apply-templates select='/XPATH/ELEMENT3' />
</fo:table-body>
<fo:table-footer />
</fo:table>
</flow>
</fo:page-sequence>
</fo:root>
<xsl:template match='/XPATH/ELEMENT1'>
<fo:block>
<xsl:value-of select='ELEMENT1'/>
</fo:block>
</xsl:template>
<xsl:template match='/XPATH/ELEMENT2'>
<fo:list-item>
<fo:list-item-label start-indent='VALUE cm' end-indent='VALUE cm'>
<fo:block>
<fo:external-graphic src='PATH.png' content-height='VALUE cm'/>
</fo:block
</fo:list-item-label>
<fo:list-item-body start-indent='body-start()' >
<fo:block>
<xsl:value-of select='ELEMENT2'/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
<xsl:template match='/XPATH/ELEMENT3'>
<fo:table-row keep-with-next='true|always'>
<fo:table-cell border-top-style='solid' border-bottom-style='solid' border-left-style='solid' border-right-style='solid' padding-top='1px' padding-bottom='1px' padding-left='1px' padding-right='1px'>
<!-- border styles: none, solid, dotted, dashed, hidden, double, inset, outset, groove, ridge -->
<xsl:value-of select='ELEMENT4'/>
</fo:table-cell>
<fo:table-cell border-style='solid' padding-top='1px' padding-bottom='1px' padding-left='1px' padding-right='1px'>
<xsl:value-of select='ELEMENT5'/>
</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
XLINK
<root xmlns:xlink='http://www.w3.org/1999/xlink'>
<-- hyperlink -->
<link xlink:type='simple|extended'
xlink:show='new|replace|embed'
xlink:actuate='onRequest|onLoad'
xlink:title='TITLE'
xlink:href='URL'>
TEXT
</link>
<-- image 1 -->
<link xlink:type='simple'
xlink:show='embed'
xlink:actuate='onLoad'
xlink:title='IMAGE TITLE'
xlink:href='PATH.png'>
</link>
<-- image 2 -->
<image />
</root>
link {
display:inline;
color:#0000FF;
text-decoration:underline;
}
image {
display:block;
background-image:url(PATH.png);
margin: 5px;
width: 600px;
height= 25px;
}
SVG
<object data='PATH.svg' type='image/svg+xml' width='NUMBER' height='NUMBER'>
<embed src='PATH.svg' type='image/svg+xml' width='NUMBER' height='NUMBER'
pluginspage='http://www.adobe.com/svg/viewer/install/' />
</object>
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version='1.0'>
<xsl:strip-space elements='*' />
<xsl:output method='xml' media-type='image/svg+xml' encoding='ISO-8859-1' indent='yes' />
<!-- % px=1unit pt=1.25units pc=15units in=90units mm=3.543307units cm=35.43307units -->
<!-- em=size of current font ex=height of current font -->
<-- svg attribute sets -->
<xsl:attribute-set name='svg-stroke'>
<xsl:attribute name='stroke'>'COLOUR'</xsl:attribute />
<xsl:attribute name='stroke-opacity'>'0-1'</xsl:attribute />
<xsl:attribute name='stroke-width'>'NUMBER'</xsl:attribute />
<xsl:attribute name='stroke-linecap'>'butt|round|square'</xsl:attribute />
<xsl:attribute name='stroke-dashaway'>'DASH,SPACE,DASH,SPACE...'</xsl:attribute />
<xsl:attribute name='stroke-dashoffset'>'NUMBER'</xsl:attribute />
<xsl:attribute name='stroke-linejoint'>'miter|round|bevel'</xsl:attribute />
</xsl:attribute-set>
<xsl:attribute-set name='svg-fill'>
<xsl:attribute name='fill'>'COLOUR|#HEX|none'</xsl:attribute />
<xsl:attribute name='fill-opacity'>'0-1'</xsl:attribute />
<xsl:attribute name='fill-rule'>'evenodd'</xsl:attribute />
</xsl:attribute-set>
<xsl:attribute-set name='svg-font'>
<xsl:attribute name='font'>'caption|small-caption|menu|icon|message-box|status-bar'</xsl:attribute />
<xsl:attribute name='font-family'>'serif|sans-serif|monospace'</xsl:attribute />
<xsl:attribute name='font-size'>'NUMBER'</xsl:attribute />
<xsl:attribute name='font-weight'>'normal|bold|bolder|lighter|100|200|...|900'</xsl:attribute />
<xsl:attribute name='font-style'>'normal|italic|oblique'</xsl:attribute />
<xsl:attribute name='font-variant'>'normal|small-caps'</xsl:attribute />
<xsl:attribute name='font-stretch'>'ultra-condensed|extra-condensed|condensed|semi-condensed|normal|semi-expanded|expanded|extra-expanded|ultra-expanded|narrower|wider'</xsl:attribute />
</xsl:attribute-set>
<xsl:attribute-set name='svg-transform'>
<xsl:attribute name='transform'>translate(x,y)</xsl:attribute /> <!-- move -->
<xsl:attribute name='transform'>scale(x,y)</xsl:attribute /> <!-- resize -->
<xsl:attribute name='transform'>rotate(DEGREES,cx,cy)</xsl:attribute /> <!-- rotate -->
<xsl:attribute name='transform'>skewX(DEGREES)</xsl:attribute /> <!-- skew x-axis -->
<xsl:attribute name='transform'>skewY(DEGREES)</xsl:attribute /> <!-- skew y-axis -->
</xsl:attribute-set>
<xsl:attribute-set name='ecma-script'>
<xsl:attribute name='onclick'>FUNCTIONNAME(evt)</xsl:attribute />
<xsl:attribute name='onmouseover'>FUNCTIONNAME(evt)</xsl:attribute />
<xsl:attribute name='onmouseout'>FUNCTIONNAME(evt)</xsl:attribute />
<xsl:attribute name='onmouseup'>FUNCTIONNAME(evt)</xsl:attribute />
<xsl:attribute name='onmousemove'>FUNCTIONNAME(evt)</xsl:attribute />
<xsl:attribute name='onmousedown'>FUNCTIONNAME(evt)</xsl:attribute />
</xsl:attribute-set>
<xsl:template match='/'>
<-- declare size of svg graphic -->
<svg width="NUMBER" height="NUMBER" viewbox="xMin yMin WIDTH HEIGHT"
preserveAspectRatio='none'
version='1.1'
onload='FUNCTIONNAME(evt)' />
<script type='text/ecmascript' xlink:href='PATH.es' />
<script type='text/ecmascript'>
<![CDATA[
<-- function uses svgDom to get and set attributes for svg elements -->
FUNCTIONNAME(evt) {
var svgDoc = evt.getTarget().getOwnerDocument();
var VARIABLE = svgDoc.getElementById('IDNAME');
var SELECTEDELEMENT = evt.getTarget();
if(SELECTEDELEMENT.nodeName = 'polygon'){
var VARIABLE = SELECTEDELEMENT.getAttribute('transform');
SELECTEDELEMEMT.setAttribute('fill', 'COLOUR');
}
var x = evt.getClientX();
var y =evt.getClientY();
}
]]>
</script>
<title>svg elements</title>
<metadata></metadata>
<desc>GROUPING</desc>
<g id='NAME' xsl:use-attribute-sets='svg-stroke svg-fill svg-font svg-transform ecma-script'>
<line x1='NUMBER' y1='NUMBER' x2='NUMBER' y2='NUMBER'
xsl:use-attribute-sets='svg-stroke ecma-script' />
<polyline points='X1,Y2 X2,Y2 X3,Y3 ...'
xsl:use-attribute-sets='svg-stroke svg-fill ecma-script' />
<rect x='NUMBER' y='NUMBER' width='NUMBER' height='NUMBER'
rx='NUMBER' ry='NUMBER' <!-- r=corner radius -->
xsl:use-attribute-sets='svg-stroke svg-fill ecma-script' />
</g>
<desc>LINK</desc>
<a id='NAME' xlink:href='URL' xsl:use-attribute-sets='svg-stroke svg-fill svg-font svg-transform ecma-script'>
<circle r='NUMBER' cx='NUMBER' cy='NUMBER' <!-- r=radius, c=centre -->
xsl:use-attribute-sets='svg-stroke svg-fill ecma-script' />
<ellipse cx='NUMBER' cy='NUMBER' rx='NUMBER' ry='NUMBER' <!-- r=radius, c=centre -->
xsl:use-attribute-sets='svg-stroke svg-fill ecma-script' />
<polygon points='X1,Y2 X2,Y2 X3,Y3 ...'
xsl:use-attribute-sets='svg-stroke svg-fill ecma-script' />
</a>
<path d="M X1,Y1 l X2,Y2 h X3 Z <!-- M=moveto, L=lineto, H=horizontal lineto Z=close path -->
m X4,Y4 L X5,Y5 V Y6" <!-- m=relative L=absolute V=vertical lineto -->
xsl:use-attribute-sets='svg-stroke svg-fill ecma-script' />
<-- C=Cubic Bezier curves, S=smooth Cubic Bezier Curve, Q=Quadratic Bezier curves, T=smooth Quadratic Bezier Curve, A=Elliptical arcs -->
<text x='NUMBER' y='NUMBER' text-anchor='start|middle|end'
xsl:use-attribute-sets='svg-stroke svg-fill svg-font ecma-script>
TEXT
<tspan xsl:use-attribute-sets='svg-stroke svg-fill svg-font ecma-script'>
TEXT
</tspan>
<tspan x='NUMBER' y='NUMBER'>
NEW LINE OF TEXT
</tspan>
</text>
<image x='NUMBER' y='NUMBER' width='NUMBER' height='NUMBER'
type='image/jpeg|png' xlink:href='PATH.jpg|png' />
</svg>
</xsl:template>
</stylesheet>






