1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- FileName: namedtemplateerr02 --> 5 <!-- Document: http://www.w3.org/TR/xslt --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 11.6 --> 8 <!-- Purpose: Error test- parameter of outer template unknown inside inner template. --> 9 <!-- Creator: David Marston --> 10 <!-- ExpectedException: Could not find variable with the name of pvar1 --> 11 12<xsl:template match="doc"> 13 <out> 14 <xsl:call-template name="tmplt1"> 15 <xsl:with-param name="pvar1" select="555"/> 16 </xsl:call-template> 17<xsl:text> 18Back to main template.</xsl:text> 19 </out> 20</xsl:template> 21 22<xsl:template name="tmplt1"> 23 <xsl:param name="pvar1">pvar1 default data</xsl:param> 24 <!-- pvar1 won't be in scope in next template, so pass it in via new variable. --> 25 <xsl:variable name="passto2"> 26 <xsl:value-of select="number($pvar1)"/> 27 </xsl:variable> 28 29 <xsl:value-of select="$passto2"/><xsl:text>, </xsl:text> 30 <xsl:call-template name="tmplt2"> 31 <xsl:with-param name="t1num" select="$passto2"/> 32 </xsl:call-template> 33 <xsl:text> 34Back to template 1.</xsl:text> 35</xsl:template> 36 37<xsl:template name="tmplt2"> 38 <xsl:param name="t1num">t1num default data</xsl:param> 39 <xsl:value-of select="444 + $t1num"/><xsl:text>, prior item should be 999, </xsl:text> 40 <xsl:value-of select="222 + $pvar1"/><xsl:text>, prior item should be 777</xsl:text> 41</xsl:template> 42 43 44 <!-- 45 * Licensed to the Apache Software Foundation (ASF) under one 46 * or more contributor license agreements. See the NOTICE file 47 * distributed with this work for additional information 48 * regarding copyright ownership. The ASF licenses this file 49 * to you under the Apache License, Version 2.0 (the "License"); 50 * you may not use this file except in compliance with the License. 51 * You may obtain a copy of the License at 52 * 53 * http://www.apache.org/licenses/LICENSE-2.0 54 * 55 * Unless required by applicable law or agreed to in writing, software 56 * distributed under the License is distributed on an "AS IS" BASIS, 57 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 58 * See the License for the specific language governing permissions and 59 * limitations under the License. 60 --> 61 62</xsl:stylesheet> 63