001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 /* 019 * $Id: ProcessorAttributeSet.java 468640 2006-10-28 06:53:53Z minchau $ 020 */ 021 package org.apache.xalan.processor; 022 023 import javax.xml.transform.TransformerException; 024 025 import org.apache.xalan.templates.ElemAttributeSet; 026 import org.apache.xalan.templates.ElemTemplateElement; 027 028 import org.xml.sax.Attributes; 029 030 /** 031 * This class processes parse events for an xsl:attribute-set. 032 * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a> 033 * @see <a href="http://www.w3.org/TR/xslt#attribute-sets">attribute-sets in XSLT Specification</a> 034 */ 035 class ProcessorAttributeSet extends XSLTElementProcessor 036 { 037 static final long serialVersionUID = -6473739251316787552L; 038 039 /** 040 * Receive notification of the start of an xsl:attribute-set element. 041 * 042 * @param handler The calling StylesheetHandler/TemplatesBuilder. 043 * @param uri The Namespace URI, or the empty string if the 044 * element has no Namespace URI or if Namespace 045 * processing is not being performed. 046 * @param localName The local name (without prefix), or the 047 * empty string if Namespace processing is not being 048 * performed. 049 * @param rawName The raw XML 1.0 name (with prefix), or the 050 * empty string if raw names are not available. 051 * @param attributes The attributes attached to the element. If 052 * there are no attributes, it shall be an empty 053 * Attributes object. 054 * 055 * @see org.apache.xalan.processor.StylesheetHandler#startElement 056 * @see org.xml.sax.ContentHandler#startElement 057 * @see org.xml.sax.ContentHandler#endElement 058 * @see org.xml.sax.Attributes 059 */ 060 public void startElement( 061 StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes) 062 throws org.xml.sax.SAXException 063 { 064 065 ElemAttributeSet eat = new ElemAttributeSet(); 066 067 eat.setLocaterInfo(handler.getLocator()); 068 try 069 { 070 eat.setPrefixes(handler.getNamespaceSupport()); 071 } 072 catch(TransformerException te) 073 { 074 throw new org.xml.sax.SAXException(te); 075 } 076 077 eat.setDOMBackPointer(handler.getOriginatingNode()); 078 setPropertiesFromAttributes(handler, rawName, attributes, eat); 079 handler.getStylesheet().setAttributeSet(eat); 080 081 // handler.pushElemTemplateElement(eat); 082 ElemTemplateElement parent = handler.getElemTemplateElement(); 083 084 parent.appendChild(eat); 085 handler.pushElemTemplateElement(eat); 086 } 087 088 /** 089 * Receive notification of the end of an element. 090 * 091 * @param name The element type name. 092 * @param attributes The specified or defaulted attributes. 093 * 094 * @param handler non-null reference to current StylesheetHandler that is constructing the Templates. 095 * @param uri The Namespace URI, or an empty string. 096 * @param localName The local name (without prefix), or empty string if not namespace processing. 097 * @param rawName The qualified name (with prefix). 098 */ 099 public void endElement( 100 StylesheetHandler handler, String uri, String localName, String rawName) 101 throws org.xml.sax.SAXException 102 { 103 handler.popElemTemplateElement(); 104 } 105 }