1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 /* 19 * $Id: ProcessorAttributeSet.java 468640 2006-10-28 06:53:53Z minchau $ 20 */ 21 package org.apache.xalan.processor; 22 23 import javax.xml.transform.TransformerException; 24 25 import org.apache.xalan.templates.ElemAttributeSet; 26 import org.apache.xalan.templates.ElemTemplateElement; 27 28 import org.xml.sax.Attributes; 29 30 /** 31 * This class processes parse events for an xsl:attribute-set. 32 * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a> 33 * @see <a href="http://www.w3.org/TR/xslt#attribute-sets">attribute-sets in XSLT Specification</a> 34 */ 35 class ProcessorAttributeSet extends XSLTElementProcessor 36 { 37 static final long serialVersionUID = -6473739251316787552L; 38 39 /** 40 * Receive notification of the start of an xsl:attribute-set element. 41 * 42 * @param handler The calling StylesheetHandler/TemplatesBuilder. 43 * @param uri The Namespace URI, or the empty string if the 44 * element has no Namespace URI or if Namespace 45 * processing is not being performed. 46 * @param localName The local name (without prefix), or the 47 * empty string if Namespace processing is not being 48 * performed. 49 * @param rawName The raw XML 1.0 name (with prefix), or the 50 * empty string if raw names are not available. 51 * @param attributes The attributes attached to the element. If 52 * there are no attributes, it shall be an empty 53 * Attributes object. 54 * 55 * @see org.apache.xalan.processor.StylesheetHandler#startElement 56 * @see org.xml.sax.ContentHandler#startElement 57 * @see org.xml.sax.ContentHandler#endElement 58 * @see org.xml.sax.Attributes 59 */ startElement( StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)60 public void startElement( 61 StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) 62 throws org.xml.sax.SAXException 63 { 64 65 ElemAttributeSet eat = new ElemAttributeSet(); 66 67 eat.setLocaterInfo(handler.getLocator()); 68 try 69 { 70 eat.setPrefixes(handler.getNamespaceSupport()); 71 } 72 catch(TransformerException te) 73 { 74 throw new org.xml.sax.SAXException(te); 75 } 76 77 eat.setDOMBackPointer(handler.getOriginatingNode()); 78 setPropertiesFromAttributes(handler, rawName, attributes, eat); 79 handler.getStylesheet().setAttributeSet(eat); 80 81 // handler.pushElemTemplateElement(eat); 82 ElemTemplateElement parent = handler.getElemTemplateElement(); 83 84 parent.appendChild(eat); 85 handler.pushElemTemplateElement(eat); 86 } 87 88 /** 89 * Receive notification of the end of an element. 90 * 91 * @param name The element type name. 92 * @param attributes The specified or defaulted attributes. 93 * 94 * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 95 * @param uri The Namespace URI, or an empty string. 96 * @param localName The local name (without prefix), or empty string if not namespace processing. 97 * @param rawName The qualified name (with prefix). 98 */ endElement( StylesheetHandler handler, String uri, String localName, String rawName)99 public void endElement( 100 StylesheetHandler handler, String uri, String localName, String rawName) 101 throws org.xml.sax.SAXException 102 { 103 handler.popElemTemplateElement(); 104 } 105 } 106