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: XSLTAttributeDef.java 468640 2006-10-28 06:53:53Z minchau $ 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xalan.processor; 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.lang.reflect.InvocationTargetException; 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.lang.reflect.Method; 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.StringTokenizer; 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.Vector; 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.TransformerException; 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.res.XSLMessages; 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.res.XSLTErrorResources; 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.templates.AVT; 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.templates.Constants; 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xalan.templates.ElemTemplateElement; 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.QName; 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.StringToIntTable; 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.StringVector; 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.XML11Char; 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xpath.XPath; 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This class defines an attribute for an element in a XSLT stylesheet, 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is meant to reflect the structure defined in http://www.w3.org/TR/xslt#dtd, and the 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * mapping between Xalan classes and the markup attributes in the element. 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class XSLTAttributeDef 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{ 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // How to handle invalid values for this attribute 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final int FATAL = 0; 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final int ERROR = 1; 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final int WARNING = 2; 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Construct an instance of XSLTAttributeDef. 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param namespace The Namespace URI, or an empty string. 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param type One of T_CDATA, T_URL, T_AVT, T_PATTERN, T_EXPR, T_CHAR, 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_NUMBER, T_YESNO, T_QNAME, T_QNAMES, T_ENUM, T_SIMPLEPATTERNLIST, 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_NMTOKEN, T_STRINGLIST, T_PREFIX_URLLIST, T_ENUM_OR_PQNAME, T_NCNAME. 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param required true if this is attribute is required by the XSLT specification. 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param supportsAVT true if this attribute supports AVT's. 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param errorType the type of error to issue if validation fails. One of FATAL, ERROR, WARNING. 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTAttributeDef(String namespace, String name, int type, boolean required, boolean supportsAVT, int errorType) 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_namespace = namespace; 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_name = name; 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_type = type; 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_required = required; 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_supportsAVT = supportsAVT; 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_errorType = errorType; 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Construct an instance of XSLTAttributeDef. 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param namespace The Namespace URI, or an empty string. 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param type One of T_CDATA, T_URL, T_AVT, T_PATTERN, T_EXPR, 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_CHAR, T_NUMBER, T_YESNO, T_QNAME, T_QNAMES, T_ENUM, 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_SIMPLEPATTERNLIST, T_NMTOKEN, T_STRINGLIST, T_PREFIX_URLLIST, 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_ENUM_OR_PQNAME, T_NCNAME. 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param supportsAVT true if this attribute supports AVT's. 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param errorType the type of error to issue if validation fails. One of FATAL, ERROR, WARNING. 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param defaultVal The default value for this attribute. 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTAttributeDef(String namespace, String name, int type, boolean supportsAVT, int errorType, String defaultVal) 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_namespace = namespace; 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_name = name; 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_type = type; 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_required = false; 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_supportsAVT = supportsAVT; 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_errorType = errorType; 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_default = defaultVal; 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Construct an instance of XSLTAttributeDef that uses two 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * enumerated values. 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param namespace The Namespace URI, or an empty string. 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param required true if this attribute is required by the XSLT specification. 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param supportsAVT true if this attribute supports AVT's. 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param prefixedQNameValAllowed If true, the type is T_ENUM_OR_PQNAME 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param errorType the type of error to issue if validation fails. One of FATAL, ERROR, WARNING. 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k1 The XSLT name of the enumerated value. 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v1 An integer representation of k1. 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k2 The XSLT name of the enumerated value. 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v2 An integer representation of k2. 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTAttributeDef(String namespace, String name, boolean required, boolean supportsAVT, 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean prefixedQNameValAllowed, int errorType, String k1, int v1, String k2, int v2) 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_namespace = namespace; 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_name = name; 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_type = prefixedQNameValAllowed ? this.T_ENUM_OR_PQNAME : this.T_ENUM; 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_required = required; 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_supportsAVT = supportsAVT; 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_errorType = errorType; 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums = new StringToIntTable(2); 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k1, v1); 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k2, v2); 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Construct an instance of XSLTAttributeDef that uses three 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * enumerated values. 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param namespace The Namespace URI, or an empty string. 1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param required true if this attribute is required by the XSLT specification. 1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param supportsAVT true if this attribute supports AVT's. 1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param prefixedQNameValAllowed If true, the type is T_ENUM_OR_PQNAME 1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param errorType the type of error to issue if validation fails. One of FATAL, ERROR, WARNING. * 1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k1 The XSLT name of the enumerated value. 1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v1 An integer representation of k1. 1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k2 The XSLT name of the enumerated value. 1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v2 An integer representation of k2. 1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k3 The XSLT name of the enumerated value. 1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v3 An integer representation of k3. 1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTAttributeDef(String namespace, String name, boolean required, boolean supportsAVT, 1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean prefixedQNameValAllowed, int errorType, String k1, int v1, String k2, int v2, String k3, int v3) 1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_namespace = namespace; 1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_name = name; 1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_type = prefixedQNameValAllowed ? this.T_ENUM_OR_PQNAME : this.T_ENUM; 1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_required = required; 1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_supportsAVT = supportsAVT; 1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_errorType = errorType; 1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums = new StringToIntTable(3); 1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k1, v1); 1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k2, v2); 1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k3, v3); 1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Construct an instance of XSLTAttributeDef that uses three 1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * enumerated values. 1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param namespace The Namespace URI, or an empty string. 1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param required true if this attribute is required by the XSLT specification. 1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param supportsAVT true if this attribute supports AVT's. 1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param prefixedQNameValAllowed If true, the type is T_ENUM_OR_PQNAME 1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param errorType the type of error to issue if validation fails. One of FATAL, ERROR, WARNING. * @param k1 The XSLT name of the enumerated value. 1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v1 An integer representation of k1. 1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k2 The XSLT name of the enumerated value. 1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v2 An integer representation of k2. 1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k3 The XSLT name of the enumerated value. 1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v3 An integer representation of k3. 1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param k4 The XSLT name of the enumerated value. 1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param v4 An integer representation of k4. 1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTAttributeDef(String namespace, String name, boolean required, boolean supportsAVT, 1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean prefixedQNameValAllowed, int errorType, String k1, int v1, String k2, int v2, 1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String k3, int v3, String k4, int v4) 1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_namespace = namespace; 1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_name = name; 1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_type = prefixedQNameValAllowed ? this.T_ENUM_OR_PQNAME : this.T_ENUM; 1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_required = required; 1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_supportsAVT = supportsAVT; 1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.m_errorType = errorType; 1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums = new StringToIntTable(4); 1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k1, v1); 1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k2, v2); 2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k3, v3); 2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_enums.put(k4, v4); 2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** Type values that represent XSLT attribute types. */ 2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final int T_CDATA = 1, 2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that is a URI reference.--> 2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_URL = 2, 2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that is an 2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // attribute value template.--> 2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_AVT = 3, // Attribute Value Template 2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that is a pattern.--> 2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_PATTERN = 4, 2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that is an expression.--> 2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_EXPR = 5, 2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that consists 2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // of a single character.--> 2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_CHAR = 6, 2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that is a number. --> 2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_NUMBER = 7, 2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for boolean values 2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_YESNO = 8, 2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for the type of an attribute value that is a QName; the prefix 2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // gets expanded by the XSLT processor. --> 2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_QNAME = 9, 2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!--Used for a whitespace-separated list of QNames where the non-prefixed 2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // entries are not to be placed in the default namespace. --> 2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_QNAMES = 10, 2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // <!-- Used for enumerated values --> 2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_ENUM = 11, 2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for simple match patterns, i.e. xsl:strip-space spec. 2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_SIMPLEPATTERNLIST = 12, 2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for a known token. 2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_NMTOKEN = 13, 2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for a list of white-space delimited strings. 2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_STRINGLIST = 14, 2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for a list of white-space delimited strings. 2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Prefixes are checked to make sure they refer to 2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // valid namespaces, and are resolved when processed 2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_PREFIX_URLLIST = 15, 2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for enumerated values, one of which could be a qname-but-not-ncname 2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_ENUM_OR_PQNAME = 16, 2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for the type of an attribute value that is a NCName 2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_NCNAME = 17, 2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for QName attributes that are always AVT. Prefix isn't resolved. 2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_AVT_QNAME = 18, 2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for a list of QNames where non-prefixed items are to be resolved 2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // using the default namespace (This is only true for cdata-section-elements) 2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_QNAMES_RESOLVE_NULL = 19, 2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Used for a list of white-space delimited strings. 2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // strings are checked to make sure they are valid 2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // prefixes, and are not expanded when processed. 2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson T_PREFIXLIST = 20; 2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** Representation for an attribute in a foreign namespace. */ 2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final XSLTAttributeDef m_foreignAttr = new XSLTAttributeDef("*", "*", 2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTAttributeDef.T_CDATA,false, false, WARNING); 2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** Method name that objects may implement if they wish to have forein attributes set. */ 2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson static final String S_FOREIGNATTR_SETTER = "setForeignAttr"; 2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The allowed namespace for this element. 2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private String m_namespace; 2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the allowed namespace for this attribute. 2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The allowed namespace for this attribute, which may be null, or may be "*". 2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String getNamespace() 2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_namespace; 2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The name of this element. 2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private String m_name; 2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the name of this attribute. 3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return non-null reference to the name of this attribute, which may be "*". 3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String getName() 3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_name; 3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The type of this attribute value. 3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private int m_type; 3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the type of this attribute value. 3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return One of T_CDATA, T_URL, T_AVT, T_PATTERN, T_EXPR, T_CHAR, 3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_NUMBER, T_YESNO, T_QNAME, T_QNAMES, T_ENUM, T_SIMPLEPATTERNLIST, 3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * T_NMTOKEN, T_STRINGLIST, T_PREFIX_URLLIST, T_ENUM_OR_PQNAME. 3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int getType() 3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_type; 3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If this element is of type T_ENUM, this will contain 3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a map from the attribute string to the Xalan integer 3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * value. 3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private StringToIntTable m_enums; 3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If this element is of type T_ENUM, this will return 3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a map from the attribute string to the Xalan integer 3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * value. 3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param key The XSLT attribute value. 3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The integer representation of the enumerated value for this attribute. 3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws Throws NullPointerException if m_enums is null. 3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private int getEnum(String key) 3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_enums.get(key); 3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If this element is of type T_ENUM, this will return 3509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * an array of strings - the values in the enumeration 3519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return An array of the enumerated values permitted for this attribute. 3539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws Throws NullPointerException if m_enums is null. 3559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private String[] getEnumNames() 3579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_enums.keys(); 3599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The default value for this attribute. 3639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private String m_default; 3659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the default value for this attribute. 3689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The default value for this attribute, or null. 3709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String getDefault() 3729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_default; 3749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the default value for this attribute. 3789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param def String representation of the default value for this attribute. 3809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setDefault(String def) 3829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_default = def; 3849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 3859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If true, this is a required attribute. 3889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private boolean m_required; 3909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 3919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 3929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get whether or not this is a required attribute. 3939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 3949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return true if this is a required attribute. 3959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 3969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean getRequired() 3979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 3989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_required; 3999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * If true, this is attribute supports AVT's. 4039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private boolean m_supportsAVT; 4059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get whether or not this attribute supports AVT's. 4089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return true if this attribute supports AVT's. 4109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean getSupportsAVT() 4129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_supportsAVT; 4149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int m_errorType = this.WARNING; 4179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the type of error message to use if the attribute value is invalid. 4209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return one of XSLAttributeDef.FATAL, XSLAttributeDef.ERROR, XSLAttributeDef.WARNING 4229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int getErrorType() 4249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_errorType; 4269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * String that should represent the setter method which which 4299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * may be used on objects to set a value that represents this attribute 4309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String m_setterString = null; 4329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Return a string that should represent the setter method. 4359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The setter method name will be created algorithmically the 4369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * first time this method is accessed, and then cached for return 4379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * by subsequent invocations of this method. 4389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 4399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return String that should represent the setter method which which 4409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * may be used on objects to set a value that represents this attribute, 4419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * of null if no setter method should be called. 4429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 4439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson public String getSetterMethodName() 4449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null == m_setterString) 4479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (m_foreignAttr == this) 4499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return S_FOREIGNATTR_SETTER; 4519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (m_name.equals("*")) 4539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_setterString = "addLiteralResultAttribute"; 4559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_setterString; 4579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringBuffer outBuf = new StringBuffer(); 4609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson outBuf.append("set"); 4629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ((m_namespace != null) 4649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson && m_namespace.equals(Constants.S_XMLNAMESPACEURI)) 4659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson outBuf.append("Xml"); 4679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int n = m_name.length(); 4709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < n; i++) 4729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson char c = m_name.charAt(i); 4749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ('-' == c) 4769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson i++; 4789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson c = m_name.charAt(i); 4809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson c = Character.toUpperCase(c); 4819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (0 == i) 4839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 4849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson c = Character.toUpperCase(c); 4859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson outBuf.append(c); 4889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson m_setterString = outBuf.toString(); 4919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return m_setterString; 4949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 4959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 4969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 4979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_AVT into 4989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a AVT value. 4999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 5019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 5029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 5039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 5049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value Should be an Attribute Value Template string. 5059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return An AVT object that may be used to evaluate the Attribute Value Template. 5079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException which will wrap a 5099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * {@link javax.xml.transform.TransformerException}, if there is a syntax error 5109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * in the attribute value template string. 5119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT processAVT( 5139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, 5149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ElemTemplateElement owner) 5159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 5169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 5199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = new AVT(handler, uri, name, rawName, value, owner); 5219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 5239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 5259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 5279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_CDATA into 5329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a String value. 5339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 5359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 5369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 5379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 5389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value non-null string reference. 5399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The value argument. 5419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException. 5439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processCDATA(StylesheetHandler handler, String uri, String name, 5459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String rawName, String value, ElemTemplateElement owner) 5469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 5479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) { 5499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 5509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = new AVT(handler, uri, name, rawName, value, owner); 5529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 5539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 5559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 5579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } else { 5599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return value; 5609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 5649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_CHAR into 5659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a Character value. 5669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 5689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 5699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 5709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 5719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value Should be a string with a length of 1. 5729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return Character object. 5749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 5759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the string is not a length of 1. 5769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 5779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processCHAR( 5789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner) 5799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 5809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) { 5829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 5839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = new AVT(handler, uri, name, rawName, value, owner); 5859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 5869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If an AVT wasn't used, validate the value 5879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ((avt.isSimple()) && (value.length() != 1)) { 5889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler, XSLTErrorResources.INVALID_TCHAR, new Object[] {name, value},null); 5899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 5909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 5929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 5949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 5959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 5969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 5979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } else { 5989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (value.length() != 1) 5999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler, XSLTErrorResources.INVALID_TCHAR, new Object[] {name, value},null); 6019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 6029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return new Character(value.charAt(0)); 6059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 6099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_ENUM into a int value. 6109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 6129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 6139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 6149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 6159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value non-null string that represents an enumerated value that is 6169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * valid for this element. 6179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param owner 6189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return An Integer representation of the enumerated value if this attribute does not support 6209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * AVT. Otherwise, and AVT is returned. 6219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 6229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processENUM(StylesheetHandler handler, String uri, String name, 6239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String rawName, String value, ElemTemplateElement owner) 6249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 6259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = null; 6289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) { 6299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 6309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson avt = new AVT(handler, uri, name, rawName, value, owner); 6329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If this attribute used an avt, then we can't validate at this time. 6349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!avt.isSimple()) return avt; 6359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 6379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 6399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int retVal = this.getEnum(value); 6439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (retVal == StringToIntTable.INVALID_KEY) 6459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringBuffer enumNamesList = getListOfEnums(); 6479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler, XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },null); 6489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 6499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) return avt; 6529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else return new Integer(retVal); 6539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 6579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of that is either an enumerated value or a qname-but-not-ncname. 6589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns an AVT, if this attribute support AVT; otherwise returns int or qname. 6599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 6619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 6629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 6639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 6649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value non-null string that represents an enumerated value that is 6659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * valid for this element. 6669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param owner 6679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 6689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return AVT if attribute supports AVT. An Integer representation of the enumerated value if 6699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute does not support AVT and an enumerated value was used. Otherwise a qname 6709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is returned. 6719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 6729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processENUM_OR_PQNAME(StylesheetHandler handler, String uri, String name, 6739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String rawName, String value, ElemTemplateElement owner) 6749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 6759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object objToReturn = null; 6789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) { 6809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 6819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = new AVT(handler, uri, name, rawName, value, owner); 6839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!avt.isSimple()) return avt; 6849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else objToReturn = avt; 6859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 6879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 6899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // An avt wasn't used. 6939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int key = this.getEnum(value); 6949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 6959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (key != StringToIntTable.INVALID_KEY) 6969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 6979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (objToReturn == null) objToReturn = new Integer(key); 6989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 6999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // enum not used. Validate qname-but-not-ncname. 7019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 7029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 7049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson QName qname = new QName(value, handler, true); 7069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (objToReturn == null) objToReturn = qname; 7079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (qname.getPrefix() == null) { 7099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringBuffer enumNamesList = getListOfEnums(); 7109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson enumNamesList.append(" <qname-but-not-ncname>"); 7129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },null); 7139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 7149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (IllegalArgumentException ie) 7189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringBuffer enumNamesList = getListOfEnums(); 7209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson enumNamesList.append(" <qname-but-not-ncname>"); 7219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },ie); 7239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 7249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (RuntimeException re) 7279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringBuffer enumNamesList = getListOfEnums(); 7299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson enumNamesList.append(" <qname-but-not-ncname>"); 7309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_ENUM,new Object[]{name, value, enumNamesList.toString() },re); 7329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 7339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return objToReturn; 7379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 7409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_EXPR into 7419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * an XPath value. 7429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 7439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 7449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 7459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 7469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 7479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value An XSLT expression string. 7489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 7499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return an XPath object that may be used for evaluation. 7509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 7519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException that wraps a 7529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * {@link javax.xml.transform.TransformerException} if the expression 7539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * string contains a syntax error. 7549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 7559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processEXPR( 7569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, 7579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ElemTemplateElement owner) 7589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 7599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 7629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XPath expr = handler.createXPath(value, owner); 7649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return expr; 7669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 7689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 7709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 7729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 7749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_NMTOKEN into 7759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a String value. 7769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 7779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 7789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 7799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 7809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 7819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A NMTOKEN string. 7829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 7839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return the value argument or an AVT if this attribute supports AVTs. 7849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 7859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the value is not a valid nmtoken 7869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 7879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processNMTOKEN(StylesheetHandler handler, String uri, String name, 7889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String rawName, String value, ElemTemplateElement owner) 7899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 7909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) { 7939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 7949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 7959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = new AVT(handler, uri, name, rawName, value, owner); 7969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 7979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If an AVT wasn't used, validate the value 7989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ((avt.isSimple()) && (!XML11Char.isXML11ValidNmtoken(value))) { 7999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_NMTOKEN, new Object[] {name,value},null); 8009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 8019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 8039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 8059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 8079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } else { 8099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!XML11Char.isXML11ValidNmtoken(value)) { 8109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_NMTOKEN, new Object[] {name,value},null); 8119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 8129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return value; 8159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 8189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_PATTERN into 8199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * an XPath match pattern value. 8209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 8219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 8229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 8239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 8249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 8259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A match pattern string. 8269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 8279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return An XPath pattern that may be used to evaluate the XPath. 8289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 8299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException that wraps a 8309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * {@link javax.xml.transform.TransformerException} if the match pattern 8319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * string contains a syntax error. 8329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 8339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processPATTERN( 8349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, 8359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ElemTemplateElement owner) 8369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 8379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 8409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XPath pattern = handler.createMatchPatternXPath(value, owner); 8429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return pattern; 8449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 8469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 8489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 8529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_NUMBER into 8539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a double value. 8549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 8559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 8569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 8579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 8589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 8599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A string that can be parsed into a double value. 8609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param number 8619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 8629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A Double object. 8639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 8649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException that wraps a 8659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * {@link javax.xml.transform.TransformerException} 8669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * if the string does not contain a parsable number. 8679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 8689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processNUMBER( 8699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner) 8709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 8719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) 8759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Double val; 8779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = null; 8789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 8799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson avt = new AVT(handler, uri, name, rawName, value, owner); 8819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If this attribute used an avt, then we can't validate at this time. 8839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (avt.isSimple()) 8849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson val = Double.valueOf(value); 8869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 8899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 8919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (NumberFormatException nfe) 8939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 8949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe); 8959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 8969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 8979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 8989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 8999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 9019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 9039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return Double.valueOf(value); 9059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (NumberFormatException nfe) 9079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_NUMBER, new Object[] {name, value}, nfe); 9099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 9109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 9159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_QNAME into a QName value. 9169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 9179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 9189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 9199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 9209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 9219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A string that represents a potentially prefix qualified name. 9229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param owner 9239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 9249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A QName object if this attribute does not support AVT's. Otherwise, an AVT 9259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is returned. 9269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 9279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the string contains a prefix that can not be 9289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * resolved, or the string contains syntax that is invalid for a qualified name. 9299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 9309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processQNAME( 9319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner) 9329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 9339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 9369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson QName qname = new QName(value, handler, true); 9389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return qname; 9399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (IllegalArgumentException ie) 9419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // thrown by QName constructor 9439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_QNAME, new Object[] {name, value},ie); 9449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 9459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (RuntimeException re) { 9479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // thrown by QName constructor 9489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_QNAME, new Object[] {name, value},re); 9499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 9509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 9559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_QNAME into a QName value. 9569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 9579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 9589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 9599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 9609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 9619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A string that represents a potentially prefix qualified name. 9629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param owner 9639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 9649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return An AVT is returned. 9659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 9669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the string contains a prefix that can not be 9679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * resolved, or the string contains syntax that is invalid for a qualified name. 9689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 9699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processAVT_QNAME( 9709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner) 9719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 9729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = null; 9759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 9769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson avt = new AVT(handler, uri, name, rawName, value, owner); 9789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If an AVT wasn't used, validate the value 9809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (avt.isSimple()) 9819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int indexOfNSSep = value.indexOf(':'); 9839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (indexOfNSSep >= 0) 9859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String prefix = value.substring(0, indexOfNSSep); 9879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!XML11Char.isXML11ValidNCName(prefix)) 9889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 9899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_QNAME,new Object[]{name,value },null); 9909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 9919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 9939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String localName = (indexOfNSSep < 0) 9959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ? value : value.substring(indexOfNSSep + 1); 9969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 9979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ((localName == null) || (localName.length() == 0) || 9989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson (!XML11Char.isXML11ValidNCName(localName))) 9999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_QNAME,new Object[]{name,value },null ); 10019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 10029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 10069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // thrown by AVT constructor 10089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 10099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 10129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 10159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type NCName into a String 10169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 10179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 10189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 10199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 10209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 10219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A string that represents a potentially prefix qualified name. 10229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param owner 10239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 10249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A String object if this attribute does not support AVT's. Otherwise, an AVT 10259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is returned. 10269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 10279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the string contains a prefix that can not be 10289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * resolved, or the string contains syntax that is invalid for a NCName. 10299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 10309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processNCNAME( 10319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner) 10329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 10339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) 10369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = null; 10389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 10399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson avt = new AVT(handler, uri, name, rawName, value, owner); 10419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If an AVT wasn't used, validate the value 10439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if ((avt.isSimple()) && (!XML11Char.isXML11ValidNCName(value))) 10449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_NCNAME,new Object[] {name,value},null); 10469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 10479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 10499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 10519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // thrown by AVT constructor 10539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 10549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } else { 10579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!XML11Char.isXML11ValidNCName(value)) 10589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler,XSLTErrorResources.INVALID_NCNAME,new Object[] {name,value},null); 10609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 10619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return value; 10639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 10679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_QNAMES into a vector of QNames where 10689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the specification requires that non-prefixed elements not be placed in a 10699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * namespace. (See section 2.4 of XSLT 1.0.) 10709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 10719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 10729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 10739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 10749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 10759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A whitespace delimited list of qualified names. 10769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 10779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return a Vector of QName objects. 10789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 10799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the one of the qualified name strings 10809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * contains a prefix that can not be 10819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * resolved, or a qualified name contains syntax that is invalid for a qualified name. 10829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 10839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector processQNAMES( 10849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value) 10859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 10869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f"); 10899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int nQNames = tokenizer.countTokens(); 10909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector qnames = new Vector(nQNames); 10919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < nQNames; i++) 10939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 10949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Fix from Alexander Rudnev 10959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson qnames.addElement(new QName(tokenizer.nextToken(), handler)); 10969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 10979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 10989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return qnames; 10999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 11029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_QNAMES_RESOLVE_NULL into a vector 11039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * of QNames where the specification requires non-prefixed elements to be 11049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * placed in the default namespace. (See section 16 of XSLT 1.0; the 11059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <em>only</em> time that this will get called is for the 11069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <code>cdata-section-elements</code> attribute on <code>xsl:output</code>. 11079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 11099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 11109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 11119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 11129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A whitespace delimited list of qualified names. 11139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return a Vector of QName objects. 11159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the one of the qualified name strings 11179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * contains a prefix that can not be resolved, or a qualified name contains 11189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * syntax that is invalid for a qualified name. 11199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 11209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson final Vector processQNAMESRNU(StylesheetHandler handler, String uri, 11219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String name, String rawName, String value) 11229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 11239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 11249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f"); 11269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int nQNames = tokenizer.countTokens(); 11279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector qnames = new Vector(nQNames); 11289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String defaultURI = handler.getNamespaceForPrefix(""); 11309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < nQNames; i++) 11319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 11329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String tok = tokenizer.nextToken(); 11339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (tok.indexOf(':') == -1) { 11349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson qnames.addElement(new QName(defaultURI,tok)); 11359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } else { 11369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson qnames.addElement(new QName(tok, handler)); 11379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return qnames; 11409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 11439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_SIMPLEPATTERNLIST into 11449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a vector of XPath match patterns. 11459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 11479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 11489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 11499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 11509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A whitespace delimited list of simple match patterns. 11519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A Vector of XPath objects. 11539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException that wraps a 11559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * {@link javax.xml.transform.TransformerException} if one of the match pattern 11569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * strings contains a syntax error. 11579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 11589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector processSIMPLEPATTERNLIST( 11599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, 11609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ElemTemplateElement owner) 11619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 11629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 11639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 11659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 11669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f"); 11679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int nPatterns = tokenizer.countTokens(); 11689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Vector patterns = new Vector(nPatterns); 11699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < nPatterns; i++) 11719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 11729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XPath pattern = 11739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handler.createMatchPatternXPath(tokenizer.nextToken(), owner); 11749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson patterns.addElement(pattern); 11769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return patterns; 11799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 11819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 11829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 11839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 11859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 11869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 11879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_STRINGLIST into 11889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a vector of XPath match patterns. 11899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 11919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 11929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 11939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 11949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value a whitespace delimited list of string values. 11959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 11969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A StringVector of the tokenized strings. 11979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 11989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringVector processSTRINGLIST(StylesheetHandler handler, String uri, 11999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String name, String rawName, String value) 12009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 12019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f"); 12039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int nStrings = tokenizer.countTokens(); 12049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringVector strings = new StringVector(nStrings); 12059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < nStrings; i++) 12079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 12089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson strings.addElement(tokenizer.nextToken()); 12099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 12109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return strings; 12129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 12139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 12159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_URLLIST into 12169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a vector of prefixes that may be resolved to URLs. 12179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 12199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 12209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 12219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 12229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A list of whitespace delimited prefixes. 12239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A vector of strings that may be resolved to URLs. 12259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if one of the prefixes can not be resolved. 12279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 12289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringVector processPREFIX_URLLIST( 12299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value) 12309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 12319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 12329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f"); 12349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int nStrings = tokenizer.countTokens(); 12359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringVector strings = new StringVector(nStrings); 12369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < nStrings; i++) 12389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 12399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String prefix = tokenizer.nextToken(); 12409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String url = handler.getNamespaceForPrefix(prefix); 12419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (url != null) 12439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson strings.addElement(url); 12449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 12459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_CANT_RESOLVE_NSPREFIX, new Object[] {prefix})); 12469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 12489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return strings; 12509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 12519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 12539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_PREFIXLIST into 12549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a vector of prefixes that may be resolved to URLs. 12559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 12579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 12589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 12599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 12609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A list of whitespace delimited prefixes. 12619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return A vector of strings that may be resolved to URLs. 12639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if one of the prefixes can not be resolved. 12659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 12669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringVector processPREFIX_LIST( 12679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, 12689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String rawName, String value) throws org.xml.sax.SAXException 12699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 12709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f"); 12729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int nStrings = tokenizer.countTokens(); 12739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringVector strings = new StringVector(nStrings); 12749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < nStrings; i++) 12769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 12779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String prefix = tokenizer.nextToken(); 12789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String url = handler.getNamespaceForPrefix(prefix); 12799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (prefix.equals(Constants.ATTRVAL_DEFAULT_PREFIX) || url != null) 12809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson strings.addElement(prefix); 12819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 12829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException( 12839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLMessages.createMessage( 12849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson XSLTErrorResources.ER_CANT_RESOLVE_NSPREFIX, 12859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson new Object[] {prefix})); 12869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 12889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return strings; 12909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 12919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 12939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 12949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_URL into 12959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a URL value. 12969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 12979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 12989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 12999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 13009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 13019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value non-null string that conforms to the URL syntax. 13029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The non-absolutized URL argument, in other words, the value argument. If this 13049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * attribute supports AVT, an AVT is returned. 13059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the URL does not conform to the URL syntax. 13079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 13089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processURL( 13099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, ElemTemplateElement owner) 13109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 13119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (getSupportsAVT()) { 13149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 13159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson AVT avt = new AVT(handler, uri, name, rawName, value, owner); 13179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If an AVT wasn't used, validate the value 13199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // if (avt.getSimpleString() != null) { 13209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // TODO: syntax check URL value. 13219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // return SystemIDResolver.getAbsoluteURI(value, 13229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // handler.getBaseIdentifier()); 13239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson //} 13249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return avt; 13259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 13269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (TransformerException te) 13279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throw new org.xml.sax.SAXException(te); 13299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 13309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } else { 13319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // TODO: syntax check URL value. 13329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // return SystemIDResolver.getAbsoluteURI(value, 13339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // handler.getBaseIdentifier()); 13349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return value; 13369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 13379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 13389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 13409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute string of type T_YESNO into 13419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a Boolean value. 13429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 13449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 13459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 13469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 13479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value A string that should be "yes" or "no". 13489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return Boolean object representation of the value. 13509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException 13529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 13539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private Boolean processYESNO( 13549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value) 13559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 13569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // Is this already checked somewhere else? -sb 13599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!(value.equals("yes") || value.equals("no"))) 13609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler, XSLTErrorResources.INVALID_BOOLEAN, new Object[] {name,value}, null); 13629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return null; 13639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 13649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return new Boolean(value.equals("yes") ? true : false); 13669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 13679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 13699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Process an attribute value. 13709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 13729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param uri The Namespace URI, or an empty string. 13739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param name The local name (without prefix), or empty string if not namespace processing. 13749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param rawName The qualified name (with prefix). 13759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param value The unprocessed string value of the attribute. 13769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The processed Object representation of the attribute. 13789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 13799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException if the attribute value can not be processed. 13809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 13819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processValue( 13829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String uri, String name, String rawName, String value, 13839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson ElemTemplateElement owner) 13849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 13859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int type = getType(); 13889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object processedValue = null; 13899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 13909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson switch (type) 13919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 13929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_AVT : 13939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processAVT(handler, uri, name, rawName, value, owner); 13949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 13959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_CDATA : 13969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processCDATA(handler, uri, name, rawName, value, owner); 13979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 13989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_CHAR : 13999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processCHAR(handler, uri, name, rawName, value, owner); 14009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_ENUM : 14029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processENUM(handler, uri, name, rawName, value, owner); 14039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_EXPR : 14059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processEXPR(handler, uri, name, rawName, value, owner); 14069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_NMTOKEN : 14089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processNMTOKEN(handler, uri, name, rawName, value, owner); 14099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_PATTERN : 14119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processPATTERN(handler, uri, name, rawName, value, owner); 14129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_NUMBER : 14149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processNUMBER(handler, uri, name, rawName, value, owner); 14159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_QNAME : 14179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processQNAME(handler, uri, name, rawName, value, owner); 14189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_QNAMES : 14209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processQNAMES(handler, uri, name, rawName, value); 14219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_QNAMES_RESOLVE_NULL: 14239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processQNAMESRNU(handler, uri, name, rawName, value); 14249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_SIMPLEPATTERNLIST : 14269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processSIMPLEPATTERNLIST(handler, uri, name, rawName, 14279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson value, owner); 14289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_URL : 14309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processURL(handler, uri, name, rawName, value, owner); 14319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_YESNO : 14339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processYESNO(handler, uri, name, rawName, value); 14349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_STRINGLIST : 14369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processSTRINGLIST(handler, uri, name, rawName, value); 14379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_PREFIX_URLLIST : 14399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processPREFIX_URLLIST(handler, uri, name, rawName, 14409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson value); 14419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_ENUM_OR_PQNAME : 14439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processENUM_OR_PQNAME(handler, uri, name, rawName, value, owner); 14449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_NCNAME : 14469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processNCNAME(handler, uri, name, rawName, value, owner); 14479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_AVT_QNAME : 14499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processAVT_QNAME(handler, uri, name, rawName, value, owner); 14509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case T_PREFIXLIST : 14529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson processedValue = processPREFIX_LIST(handler, uri, name, rawName, 14539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson value); 14549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 14559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson default : 14579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 14589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return processedValue; 14609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 14619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 14639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set the default value of an attribute. 14649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 14659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 14669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param elem The object on which the property will be set. 14679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 14689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException wraps an invocation exception if the 14699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * setter method can not be invoked on the object. 14709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 14719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void setDefAttrValue(StylesheetHandler handler, ElemTemplateElement elem) 14729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 14739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 14749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson setAttrValue(handler, this.getNamespace(), this.getName(), 14759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson this.getName(), this.getDefault(), elem); 14769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 14779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 14799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Get the primative type for the class, if there 14809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * is one. If the class is a Double, for instance, 14819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * this will return double.class. If the class is not one 14829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * of the 9 primative types, it will return the same 14839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * class that was passed in. 14849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 14859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param obj The object which will be resolved to a primative class object if possible. 14869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 14879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @return The most primative class representation possible for the object, never null. 14889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 14899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private Class getPrimativeClass(Object obj) 14909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 14919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (obj instanceof XPath) 14939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return XPath.class; 14949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Class cl = obj.getClass(); 14969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 14979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (cl == Double.class) 14989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 14999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = double.class; 15009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (cl == Float.class) 15039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = float.class; 15059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (cl == Boolean.class) 15079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = boolean.class; 15099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (cl == Byte.class) 15119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = byte.class; 15139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (cl == Character.class) 15159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = char.class; 15179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (cl == Short.class) 15199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = short.class; 15219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (cl == Integer.class) 15239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = int.class; 15259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else if (cl == Long.class) 15279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson cl = long.class; 15299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return cl; 15329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 15359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * StringBuffer containing comma delimited list of valid values for ENUM type. 15369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Used to build error message. 15379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 15389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private StringBuffer getListOfEnums() 15399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StringBuffer enumNamesList = new StringBuffer(); 15419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String [] enumValues = this.getEnumNames(); 15429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson for (int i = 0; i < enumValues.length; i++) 15449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (i > 0) 15469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson enumNamesList.append(' '); 15489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson enumNamesList.append(enumValues[i]); 15509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return enumNamesList; 15529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 15559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Set a value on an attribute. 15569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 15579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 15589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param attrUri The Namespace URI of the attribute, or an empty string. 15599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param attrLocalName The local name (without prefix), or empty string if not namespace processing. 15609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param attrRawName The raw name of the attribute, including possible prefix. 15619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param attrValue The attribute's value. 15629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @param elem The object that should contain a property that represents the attribute. 15639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 15649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @throws org.xml.sax.SAXException 15659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 15669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson boolean setAttrValue( 15679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson StylesheetHandler handler, String attrUri, String attrLocalName, 15689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String attrRawName, String attrValue, ElemTemplateElement elem) 15699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson throws org.xml.sax.SAXException 15709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if(attrRawName.equals("xmlns") || attrRawName.startsWith("xmlns:")) 15729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return true; 15739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson String setterString = getSetterMethodName(); 15759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If this is null, then it is a foreign namespace and we 15779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // do not process it. 15789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null != setterString) 15799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 15819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Method meth; 15839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object[] args; 15849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if(setterString.equals(S_FOREIGNATTR_SETTER)) 15869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 15879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // workaround for possible crimson bug 15889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if( attrUri==null) attrUri=""; 15899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // First try to match with the primative value. 15909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Class sclass = attrUri.getClass(); 15919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Class[] argTypes = new Class[]{ sclass, sclass, 15929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson sclass, sclass }; 15939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson meth = elem.getClass().getMethod(setterString, argTypes); 15959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 15969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson args = new Object[]{ attrUri, attrLocalName, 15979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson attrRawName, attrValue }; 15989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 15999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson else 16009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Object value = processValue(handler, attrUri, attrLocalName, 16029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson attrRawName, attrValue, elem); 16039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If a warning was issued because the value for this attribute was 16049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // invalid, then the value will be null. Just return 16059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (null == value) return false; 16069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // First try to match with the primative value. 16089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Class[] argTypes = new Class[]{ getPrimativeClass(value) }; 16099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson try 16119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson meth = elem.getClass().getMethod(setterString, argTypes); 16139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (NoSuchMethodException nsme) 16159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Class cl = ((Object) value).getClass(); 16179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson // If this doesn't work, try it with the non-primative value; 16199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson argTypes[0] = cl; 16209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson meth = elem.getClass().getMethod(setterString, argTypes); 16219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson args = new Object[]{ value }; 16249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson meth.invoke(elem, args); 16279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (NoSuchMethodException nsme) 16299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson if (!setterString.equals(S_FOREIGNATTR_SETTER)) 16319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handler.error(XSLTErrorResources.ER_FAILED_CALLING_METHOD, new Object[]{setterString}, nsme);//"Failed calling " + setterString + " method!", nsme); 16339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return false; 16349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (IllegalAccessException iae) 16379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handler.error(XSLTErrorResources.ER_FAILED_CALLING_METHOD, new Object[]{setterString}, iae);//"Failed calling " + setterString + " method!", iae); 16399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return false; 16409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson catch (InvocationTargetException nsme) 16429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handleError(handler, XSLTErrorResources.WG_ILLEGAL_ATTRIBUTE_VALUE, 16449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson new Object[]{ Constants.ATTRNAME_NAME, getName()}, nsme); 16459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return false; 16469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson return true; 16509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 16529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson private void handleError(StylesheetHandler handler, String msg, Object [] args, Exception exc) throws org.xml.sax.SAXException 16539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson switch (getErrorType()) 16559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson { 16569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case (FATAL): 16579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case (ERROR): 16589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handler.error(msg, args, exc); 16599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson break; 16609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson case (WARNING): 16619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson handler.warn(msg, args); 16629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson default: break; 16639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson } 16659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} 1666