KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > processor > ProcessorStripSpace


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: ProcessorStripSpace.java,v 1.11 2004/02/11 18:15:51 minchau Exp $
18  */

19 package org.apache.xalan.processor;
20
21 import java.util.Vector JavaDoc;
22
23 import org.apache.xalan.templates.Stylesheet;
24 import org.apache.xalan.templates.WhiteSpaceInfo;
25 import org.apache.xpath.XPath;
26
27 import org.xml.sax.Attributes JavaDoc;
28
29 /**
30  * TransformerFactory for xsl:strip-space markup.
31  * <pre>
32  * <!ELEMENT xsl:strip-space EMPTY>
33  * <!ATTLIST xsl:strip-space elements CDATA #REQUIRED>
34  * </pre>
35  */

36 class ProcessorStripSpace extends ProcessorPreserveSpace
37 {
38
39   /**
40    * Receive notification of the start of an strip-space element.
41    *
42    * @param handler The calling StylesheetHandler/TemplatesBuilder.
43    * @param uri The Namespace URI, or the empty string if the
44    * element has no Namespace URI or if Namespace
45    * processing is not being performed.
46    * @param localName The local name (without prefix), or the
47    * empty string if Namespace processing is not being
48    * performed.
49    * @param rawName The raw XML 1.0 name (with prefix), or the
50    * empty string if raw names are not available.
51    * @param attributes The attributes attached to the element. If
52    * there are no attributes, it shall be an empty
53    * Attributes object.
54    */

55   public void startElement(
56           StylesheetHandler handler, String JavaDoc uri, String JavaDoc localName, String JavaDoc rawName, Attributes JavaDoc attributes)
57             throws org.xml.sax.SAXException JavaDoc
58   {
59     Stylesheet thisSheet = handler.getStylesheet();
60     WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
61     setPropertiesFromAttributes(handler, rawName, attributes, paths);
62
63     Vector JavaDoc xpaths = paths.getElements();
64
65     for (int i = 0; i < xpaths.size(); i++)
66     {
67       WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), true, thisSheet);
68       wsi.setUid(handler.nextUid());
69
70       thisSheet.setStripSpaces(wsi);
71     }
72     paths.clearElements();
73
74   }
75 }
76
Popular Tags