Home | History | Annotate | Download | only in processor
      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: ProcessorStripSpace.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:strip-space markup.
     33  * <pre>
     34  * <!ELEMENT xsl:strip-space EMPTY>
     35  * <!ATTLIST xsl:strip-space elements CDATA #REQUIRED>
     36  * </pre>
     37  */
     38 class ProcessorStripSpace extends ProcessorPreserveSpace
     39 {
     40     static final long serialVersionUID = -5594493198637899591L;
     41 
     42   /**
     43    * Receive notification of the start of an strip-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, Attributes attributes)
     60             throws org.xml.sax.SAXException
     61   {
     62     Stylesheet thisSheet = handler.getStylesheet();
     63 	WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
     64     setPropertiesFromAttributes(handler, rawName, attributes, paths);
     65 
     66     Vector xpaths = paths.getElements();
     67 
     68     for (int i = 0; i < xpaths.size(); i++)
     69     {
     70       WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), true, thisSheet);
     71       wsi.setUid(handler.nextUid());
     72 
     73       thisSheet.setStripSpaces(wsi);
     74     }
     75     paths.clearElements();
     76 
     77   }
     78 }
     79