1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/*
* SPL - The SPL Programming Language
* Copyright (C) 2004, 2005 Clifford Wolf <clifford@clifford.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* example53.spl: simple XSLT example
*/
// SKIP_IF_NO_LIBXML2
// SKIP_IF_NO_LIBXSLT
load "xml";
var xmldoc = xml_parse(<:>
: <?xml version="1.0"?>
: <swlist>
: <software name="ROCK Linux">
: <author>Clifford Wolf</author>
: <desc>Distribution Built Kit</desc>
: </software>
: <software name="dietlibc">
: <author>Felix von Leitner</author>
: <desc>A small C library</desc>
: </software>
: <software name="gatling">
: <author>Felix von Leitner</author>
: <desc>A high performance web server</desc>
: </software>
: <software name="Ambassador of Pain">
: <author>Raffi and Clifford</author>
: <desc>A game for the text console</desc>
: </software>
: <software name="SPL">
: <author>Clifford Wolf</author>
: <desc>Yet another Scripting Language</desc>
: </software>
: </swlist>
</>);
var xsldoc = xml_parse(<:>
: <?xml version="1.0"?>
: <xsl:stylesheet version="1.0"
: xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
: xmlns:set="http://exslt.org/sets"
: extension-element-prefixes="set">
: <xsl:output method="xml" indent="yes"/>
: <xsl:param name="ignore"/>
: <xsl:template match="/">
: <swlist-by-author>
: <xsl:for-each select="swlist/software[
: not(author = preceding-sibling::software/author) and
: not(string-length($$ignore) > 0 and contains(author, $$ignore))]">
: <author name="{author}">
: <xsl:variable name="a" select="author"/>
: <xsl:for-each select="../software[string(author)=$$a]">
: <software>
: <name><xsl:value-of select="@name"/></name>
: <desc><xsl:value-of select="desc"/></desc>
: </software>
: </xsl:for-each>
: </author>
: </xsl:for-each>
: <exslt-demo>
: <xsl:for-each select="set:distinct(//author)">
: <author><xsl:value-of select="." /></author>
: </xsl:for-each>
: </exslt-demo>
: </swlist-by-author>
: </xsl:template>
: </xsl:stylesheet>
</>);
debug xml_xslt_text(xmldoc, xsldoc, ignore: "'Raffi'");
|