14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file 44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information 54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file 64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License. 84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at 94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software 134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and 164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License. 174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: ProcessorAttributeSet.java 468640 2006-10-28 06:53:53Z minchau $ 204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xalan.processor; 224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport javax.xml.transform.TransformerException; 244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xalan.templates.ElemAttributeSet; 264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xalan.templates.ElemTemplateElement; 274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.Attributes; 294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/** 314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This class processes parse events for an xsl:attribute-set. 324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a> 334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see <a href="http://www.w3.org/TR/xslt#attribute-sets">attribute-sets in XSLT Specification</a> 344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonclass ProcessorAttributeSet extends XSLTElementProcessor 364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson{ 374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson static final long serialVersionUID = -6473739251316787552L; 384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Receive notification of the start of an xsl:attribute-set element. 414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param handler The calling StylesheetHandler/TemplatesBuilder. 434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param uri The Namespace URI, or the empty string if the 444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * element has no Namespace URI or if Namespace 454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * processing is not being performed. 464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param localName The local name (without prefix), or the 474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * empty string if Namespace processing is not being 484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * performed. 494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param rawName The raw XML 1.0 name (with prefix), or the 504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * empty string if raw names are not available. 514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param attributes The attributes attached to the element. If 524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * there are no attributes, it shall be an empty 534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Attributes object. 544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see org.apache.xalan.processor.StylesheetHandler#startElement 564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see org.xml.sax.ContentHandler#startElement 574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see org.xml.sax.ContentHandler#endElement 584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see org.xml.sax.Attributes 594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startElement( 614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) 624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson ElemAttributeSet eat = new ElemAttributeSet(); 664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson eat.setLocaterInfo(handler.getLocator()); 684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson try 694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson eat.setPrefixes(handler.getNamespaceSupport()); 714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson catch(TransformerException te) 734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throw new org.xml.sax.SAXException(te); 754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson eat.setDOMBackPointer(handler.getOriginatingNode()); 784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson setPropertiesFromAttributes(handler, rawName, attributes, eat); 794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson handler.getStylesheet().setAttributeSet(eat); 804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // handler.pushElemTemplateElement(eat); 824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson ElemTemplateElement parent = handler.getElemTemplateElement(); 834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson parent.appendChild(eat); 854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson handler.pushElemTemplateElement(eat); 864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Receive notification of the end of an element. 904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param name The element type name. 924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param attributes The specified or defaulted attributes. 934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param uri The Namespace URI, or an empty string. 964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param localName The local name (without prefix), or empty string if not namespace processing. 974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param rawName The qualified name (with prefix). 984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endElement( 1004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson StylesheetHandler handler, String uri, String localName, String rawName) 1014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 1024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 1034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson handler.popElemTemplateElement(); 1044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 1054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson} 106