19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License. 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License. 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: ElemTemplate.java 468643 2006-10-28 06:56:03Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan.templates; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.SourceLocator; 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.TransformerException; 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.transformer.TransformerImpl; 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.QName; 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xpath.XPath; 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xpath.XPathContext; 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Implement xsl:template. 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <pre> 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <!ELEMENT xsl:template 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * (#PCDATA 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * %instructions; 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * %result-elements; 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * | xsl:param) 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * > 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <!ATTLIST xsl:template 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * match %pattern; #IMPLIED 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * name %qname; #IMPLIED 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * priority %priority; #IMPLIED 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * mode %qname; #IMPLIED 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * %space-att; 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * > 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </pre> 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#section-Defining-Template-Rules">section-Defining-Template-Rules in XSLT Specification</a> 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @xsl.usage advanced 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class ElemTemplate extends ElemTemplateElement 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{ 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final long serialVersionUID = -5283056789965384058L; 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** The public identifier for the current document event. 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial */ 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private String m_publicId; 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** The system identifier for the current document event. 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial */ 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private String m_systemId; 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Return the public identifier for the current document event. 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>This will be the public identifier 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A string containing the public identifier, or 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * null if none is available. 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see #getSystemId 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public String getPublicId() 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_publicId; 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Return the system identifier for the current document event. 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>If the system identifier is a URL, the parser must resolve it 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * fully before passing it to the application.</p> 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A string containing the system identifier, or null 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if none is available. 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see #getPublicId 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public String getSystemId() 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_systemId; 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the location information for this element. 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param locator SourceLocator holding location information 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setLocaterInfo(SourceLocator locator) 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_publicId = locator.getPublicId(); 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_systemId = locator.getSystemId(); 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson super.setLocaterInfo(locator); 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The owning stylesheet. 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * (Should this only be put on the template element, to 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * conserve space?) 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private Stylesheet m_stylesheet; 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the stylesheet composed (resolves includes and 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * imports and has methods on it that return "composed" properties. 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The stylesheet composed. 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public StylesheetComposed getStylesheetComposed() 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_stylesheet.getStylesheetComposed(); 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the owning stylesheet. 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The owning stylesheet. 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public Stylesheet getStylesheet() 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_stylesheet; 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the owning stylesheet. 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param sheet The owning stylesheet for this element 1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setStylesheet(Stylesheet sheet) 1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_stylesheet = sheet; 1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the root stylesheet. 1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The root stylesheet for this element 1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public StylesheetRoot getStylesheetRoot() 1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_stylesheet.getStylesheetRoot(); 1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The match attribute is a Pattern that identifies the source 1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * node or nodes to which the rule applies. 1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private XPath m_matchPattern = null; 1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the "match" attribute. 1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The match attribute is a Pattern that identifies the source 1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * node or nodes to which the rule applies. The match attribute 1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is required unless the xsl:template element has a name 1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute (see [6 Named Templates]). It is an error for the 1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * value of the match attribute to contain a VariableReference. 1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#patterns">patterns in XSLT Specification</a> 1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v Value to set for the "match" attribute 1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setMatch(XPath v) 1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_matchPattern = v; 1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the "match" attribute. 1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The match attribute is a Pattern that identifies the source 1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * node or nodes to which the rule applies. The match attribute 1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is required unless the xsl:template element has a name 1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute (see [6 Named Templates]). It is an error for the 1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * value of the match attribute to contain a VariableReference. 1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#patterns">patterns in XSLT Specification</a> 1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return Value of the "match" attribute 1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public XPath getMatch() 1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_matchPattern; 1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * An xsl:template element with a name attribute specifies a named template. 1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private QName m_name = null; 1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the "name" attribute. 2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * An xsl:template element with a name attribute specifies a named template. 2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If an xsl:template element has a name attribute, it may, but need not, 2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * also have a match attribute. 2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#named-templates">named-templates in XSLT Specification</a> 2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v Value to set the "name" attribute 2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setName(QName v) 2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_name = v; 2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the "name" attribute. 2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * An xsl:template element with a name attribute specifies a named template. 2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If an xsl:template element has a name attribute, it may, but need not, 2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * also have a match attribute. 2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#named-templates">named-templates in XSLT Specification</a> 2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return Value of the "name" attribute 2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public QName getName() 2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_name; 2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Modes allow an element to be processed multiple times, 2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * each time producing a different result. 2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private QName m_mode; 2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the "mode" attribute. 2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Modes allow an element to be processed multiple times, 2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * each time producing a different result. If xsl:template 2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * does not have a match attribute, it must not have a mode attribute. 2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#modes">modes in XSLT Specification</a> 2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v Value to set the "mode" attribute 2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setMode(QName v) 2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_mode = v; 2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the "mode" attribute. 2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Modes allow an element to be processed multiple times, 2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * each time producing a different result. If xsl:template 2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * does not have a match attribute, it must not have a mode attribute. 2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#modes">modes in XSLT Specification</a> 2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return Value of the "mode" attribute 2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public QName getMode() 2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_mode; 2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The priority of a template rule is specified by the priority 2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute on the template rule. 2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @serial 2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private double m_priority = XPath.MATCH_SCORE_NONE; 2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the "priority" attribute. 2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The priority of a template rule is specified by the priority 2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute on the template rule. The value of this must be a 2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * real number (positive or negative), matching the production 2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Number with an optional leading minus sign (-). 2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#conflict">conflict in XSLT Specification</a> 2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v The value to set for the "priority" attribute 2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void setPriority(double v) 2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_priority = v; 2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the "priority" attribute. 2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The priority of a template rule is specified by the priority 2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute on the template rule. The value of this must be a 2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * real number (positive or negative), matching the production 2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Number with an optional leading minus sign (-). 2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#conflict">conflict in XSLT Specification</a> 2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The value of the "priority" attribute 2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public double getPriority() 2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_priority; 2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get an int constant identifying the type of element. 3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @see org.apache.xalan.templates.Constants 3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The token ID for the element 3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int getXSLToken() 3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return Constants.ELEMNAME_TEMPLATE; 3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Return the node name. 3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The element's name 3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public String getNodeName() 3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return Constants.ELEMNAME_TEMPLATE_STRING; 3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The stack frame size for this template, which is equal to the maximum number 3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * of params and variables that can be declared in the template at one time. 3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public int m_frameSize; 3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The size of the portion of the stack frame that can hold parameter 3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * arguments. 3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_inArgsSize; 3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * List of namespace/local-name pairs, DTM style, that are unique 3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * qname identifiers for the arguments. The position of a given qname 3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * in the list is the argument ID, and thus the position in the stack 3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * frame. 3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private int[] m_argsQNameIDs; 3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is called after everything else has been 3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * recomposed, and allows the template to set remaining 3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * values that may be based on some other property that 3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * depends on recomposition. 3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void compose(StylesheetRoot sroot) throws TransformerException 3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson super.compose(sroot); 3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetRoot.ComposeState cstate = sroot.getComposeState(); 3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson java.util.Vector vnames = cstate.getVariableNames(); 3509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if(null != m_matchPattern) 3519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_matchPattern.fixupVariables(vnames, sroot.getComposeState().getGlobalsSize()); 3529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cstate.resetStackFrameSize(); 3549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_inArgsSize = 0; 3559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This after the template's children have been composed. 3599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void endCompose(StylesheetRoot sroot) throws TransformerException 3619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetRoot.ComposeState cstate = sroot.getComposeState(); 3639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson super.endCompose(sroot); 3649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_frameSize = cstate.getFrameSize(); 3659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cstate.resetStackFrameSize(); 3679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Copy the template contents into the result tree. 3719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The content of the xsl:template element is the template 3729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * that is instantiated when the template rule is applied. 3739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param transformer non-null reference to the the current transform-time state. 3759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws TransformerException 3779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void execute( 3799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson TransformerImpl transformer) 3809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws TransformerException 3819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XPathContext xctxt = transformer.getXPathContext(); 3839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson xctxt.pushRTFContext(); 3859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // %REVIEW% commenting out of the code below. 3879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// if (null != sourceNode) 3889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// { 3899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson transformer.executeChildTemplates(this, true); 3909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// } 3919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// else // if(null == sourceNode) 3929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// { 3939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// transformer.getMsgMgr().error(this, 3949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// this, sourceNode, 3959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES); 3969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 3979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// //"sourceNode is null in handleApplyTemplatesInstruction!"); 3989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// } 3999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson xctxt.popRTFContext(); 4019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is called during recomposition to 4059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * control how this element is composed. 4069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param root The root stylesheet for this transformation. 4079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public void recompose(StylesheetRoot root) 4099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson root.recomposeTemplates(this); 4119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 414