1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 5<xsl:template match="GrandKids" mode="orginal"> 6They have <xsl:value-of select="count(*)"/> grandchildren: <xsl:text/> 7 <xsl:for-each select="gkid"> 8 <xsl:value-of select="key('KidInfo',(.))/Name/@First"/> 9 <xsl:if test="not(position()=last())">, </xsl:if> 10 <xsl:if test="(position()=last()-1)">and </xsl:if> 11 </xsl:for-each> 12</xsl:template> 13 14<xsl:template match="GrandKids" mode="document"> 15They should have <xsl:value-of select="count(document('grandkids.xml')/GrandKids/gkid)"/> grandchildren: <xsl:text/> 16 <xsl:for-each select="gkid"> 17 <xsl:value-of select="key('KidInfo',.)/Name/@First"/> 18 <xsl:if test="not(position()=last())">, </xsl:if> 19 <xsl:if test="(position()=last()-1)">and </xsl:if> 20 </xsl:for-each> 21</xsl:template> 22 23<xsl:template match="GrandKids" mode="doc"> 24They got <xsl:value-of select="count(document('grandkids.xml')/GrandKids/gkid)"/> grandchildren: <xsl:text/> 25 <xsl:for-each select="document('grandkids.xml')/GrandKids/gkid"> 26 <xsl:value-of select="key('KidInfo',(.))/Name/@First"/> 27 <xsl:if test="not(position()=last())">, </xsl:if> 28 <xsl:if test="(position()=last()-1)">and </xsl:if> 29 </xsl:for-each> 30</xsl:template> 31 32 33 <!-- 34 * Licensed to the Apache Software Foundation (ASF) under one 35 * or more contributor license agreements. See the NOTICE file 36 * distributed with this work for additional information 37 * regarding copyright ownership. The ASF licenses this file 38 * to you under the Apache License, Version 2.0 (the "License"); 39 * you may not use this file except in compliance with the License. 40 * You may obtain a copy of the License at 41 * 42 * http://www.apache.org/licenses/LICENSE-2.0 43 * 44 * Unless required by applicable law or agreed to in writing, software 45 * distributed under the License is distributed on an "AS IS" BASIS, 46 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 * See the License for the specific language governing permissions and 48 * limitations under the License. 49 --> 50 51</xsl:stylesheet> 52