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: ProcessorStripSpace.java 468640 2006-10-28 06:53:53Z minchau $
020 */
021 package org.apache.xalan.processor;
022
023 import java.util.Vector;
024
025 import org.apache.xalan.templates.Stylesheet;
026 import org.apache.xalan.templates.WhiteSpaceInfo;
027 import org.apache.xpath.XPath;
028
029 import org.xml.sax.Attributes;
030
031 /**
032 * TransformerFactory for xsl:strip-space markup.
033 * <pre>
034 * <!ELEMENT xsl:strip-space EMPTY>
035 * <!ATTLIST xsl:strip-space elements CDATA #REQUIRED>
036 * </pre>
037 */
038 class ProcessorStripSpace extends ProcessorPreserveSpace
039 {
040 static final long serialVersionUID = -5594493198637899591L;
041
042 /**
043 * Receive notification of the start of an strip-space element.
044 *
045 * @param handler The calling StylesheetHandler/TemplatesBuilder.
046 * @param uri The Namespace URI, or the empty string if the
047 * element has no Namespace URI or if Namespace
048 * processing is not being performed.
049 * @param localName The local name (without prefix), or the
050 * empty string if Namespace processing is not being
051 * performed.
052 * @param rawName The raw XML 1.0 name (with prefix), or the
053 * empty string if raw names are not available.
054 * @param attributes The attributes attached to the element. If
055 * there are no attributes, it shall be an empty
056 * Attributes object.
057 */
058 public void startElement(
059 StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
060 throws org.xml.sax.SAXException
061 {
062 Stylesheet thisSheet = handler.getStylesheet();
063 WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
064 setPropertiesFromAttributes(handler, rawName, attributes, paths);
065
066 Vector xpaths = paths.getElements();
067
068 for (int i = 0; i < xpaths.size(); i++)
069 {
070 WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), true, thisSheet);
071 wsi.setUid(handler.nextUid());
072
073 thisSheet.setStripSpaces(wsi);
074 }
075 paths.clearElements();
076
077 }
078 }