Jul 03, 2013 Distinct values in XSLT 1.0. GitHub Gist: instantly share code, notes, and snippets. Skip to content. All gists Back to GitHub. Sign in Sign up Instantly share code, notes, and snippets. DiogoDoreto / XSLT 1.0. Created Jul 3, 2013. Star 4 Fork 0; Code Revisions 1 Stars 4.
<?xml version='1.0' encoding='UTF-8'?> |
<xsl:stylesheetxmlns:xsl='http://www.w3.org/1999/XSL/Transform' |
xmlns:xs='http://www.w3.org/2001/XMLSchema' |
xmlns:math='http://www.w3.org/2005/xpath-functions/math' |
exclude-result-prefixes='xs math' |
expand-text='yes' |
version='3.0'> |
<xsl:modestreamable='yes'use-accumulators='#all'on-no-match='shallow-skip'/> |
<xsl:outputindent='yes'/> |
<xsl:accumulatorname='row-count'as='xs:integer'initial-value='0'streamable='yes'> |
<xsl:accumulator-rulematch='row'select='$value + 1'/> |
</xsl:accumulator> |
<xsl:accumulatorname='col-count'as='xs:integer'initial-value='0'streamable='yes'> |
<xsl:accumulator-rulematch='row'select='0'/> |
<xsl:accumulator-rulematch='row/col'select='$value + 1'/> |
</xsl:accumulator> |
<xsl:templatematch='root'> |
<xsl:copy> |
<xsl:apply-templates/> |
</xsl:copy> |
</xsl:template> |
<xsl:templatematch='col'> |
<datarow='{accumulator-before('row-count')}'col='{accumulator-before('col-count')}'>{.}</data> |
</xsl:template> |
</xsl:stylesheet> |
<xsl:key> tag element specifies a named name-value pair assigned to a specific element in an XML document. This key is used with the key() function in XPath expressions to access the assigned elements in an XML document.
Following is the syntax declaration of <xsl:key> element.
S.No | Name & Description |
---|---|
1 | Name Name of the key to be used. |
2 | Match Patterns used to identify a node that holds this key. |
3 | Dll files fixer license key generator.rar. Use XPath expression to identify the value of the nodes of xml document. |
Number of Occurrences | Unlimited |
Parent elements | xsl:stylesheet |
Child elements | None |
This example creates a table of <student> element with its attribute rollno and its child <firstname>, <lastname>, <nickname>, and <marks> by iterating over each student. It checks key as firstname to be one of the student's name and then prints the student details.
students.xml
students.xsl