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: ProcessorPreserveSpace.java 468640 2006-10-28 06:53:53Z minchau $ 20 */ 21 package org.apache.xalan.processor; 22 23 import java.util.Vector; 24 25 import org.apache.xalan.templates.Stylesheet; 26 import org.apache.xalan.templates.WhiteSpaceInfo; 27 import org.apache.xpath.XPath; 28 29 import org.xml.sax.Attributes; 30 31 /** 32 * TransformerFactory for xsl:preserve-space markup. 33 * <pre> 34 * <!ELEMENT xsl:preserve-space EMPTY> 35 * <!ATTLIST xsl:preserve-space elements CDATA #REQUIRED> 36 * </pre> 37 */ 38 class ProcessorPreserveSpace extends XSLTElementProcessor 39 { 40 static final long serialVersionUID = -5552836470051177302L; 41 42 /** 43 * Receive notification of the start of an preserve-space element. 44 * 45 * @param handler The calling StylesheetHandler/TemplatesBuilder. 46 * @param uri The Namespace URI, or the empty string if the 47 * element has no Namespace URI or if Namespace 48 * processing is not being performed. 49 * @param localName The local name (without prefix), or the 50 * empty string if Namespace processing is not being 51 * performed. 52 * @param rawName The raw XML 1.0 name (with prefix), or the 53 * empty string if raw names are not available. 54 * @param attributes The attributes attached to the element. If 55 * there are no attributes, it shall be an empty 56 * Attributes object. 57 */ 58 public void startElement( 59 StylesheetHandler handler, String uri, String localName, String rawName, 60 Attributes attributes) 61 throws org.xml.sax.SAXException 62 { 63 Stylesheet thisSheet = handler.getStylesheet(); 64 WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet); 65 setPropertiesFromAttributes(handler, rawName, attributes, paths); 66 67 Vector xpaths = paths.getElements(); 68 69 for (int i = 0; i < xpaths.size(); i++) 70 { 71 WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), false, thisSheet); 72 wsi.setUid(handler.nextUid()); 73 74 thisSheet.setPreserveSpaces(wsi); 75 } 76 paths.clearElements(); 77 } 78 } 79