1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:lxslt="http://xml.apache.org/xslt" 4 xmlns:counter="MyCounter" 5 extension-element-prefixes="counter" 6 exclude-result-prefixes="lxslt" 7 version="1.0"> 8 9 10 <lxslt:component prefix="counter" 11 elements="init incr" functions="read"> 12 <lxslt:script lang="javaclass" src="javaSample4"/> 13 </lxslt:component> 14 15 <xsl:template match="/"> 16 <HTML> 17 <H1>Java Example</H1> 18 <counter:init name="index" value="1"/> 19 <p>Here are the names in alphabetical order by last name:</p> 20 <xsl:for-each select="doc/name"> 21 <xsl:sort select="@last"/> 22 <xsl:sort select="@first"/> 23 <p> 24 <xsl:text>[</xsl:text> 25 <xsl:value-of select="counter:read('index')"/> 26 <xsl:text>]. </xsl:text> 27 <xsl:value-of select="@last"/> 28 <xsl:text>, </xsl:text> 29 <xsl:value-of select="@first"/> 30 </p> 31 <counter:incr name="index"/> 32 </xsl:for-each> 33 </HTML> 34 </xsl:template> 35 36 37 <!-- 38 * Licensed to the Apache Software Foundation (ASF) under one 39 * or more contributor license agreements. See the NOTICE file 40 * distributed with this work for additional information 41 * regarding copyright ownership. The ASF licenses this file 42 * to you under the Apache License, Version 2.0 (the "License"); 43 * you may not use this file except in compliance with the License. 44 * You may obtain a copy of the License at 45 * 46 * http://www.apache.org/licenses/LICENSE-2.0 47 * 48 * Unless required by applicable law or agreed to in writing, software 49 * distributed under the License is distributed on an "AS IS" BASIS, 50 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 51 * See the License for the specific language governing permissions and 52 * limitations under the License. 53 --> 54 55</xsl:stylesheet> 56