KickJava   Java API By Example, From Geeks To Geeks.

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


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: ProcessorPreserveSpace.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:preserve-space markup.
31  * <pre>
32  * <!ELEMENT xsl:preserve-space EMPTY>
33  * <!ATTLIST xsl:preserve-space elements CDATA #REQUIRED>
34  * </pre>
35  */

36 class ProcessorPreserveSpace extends XSLTElementProcessor
37 {
38
39   /**
40    * Receive notification of the start of an preserve-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,
57           Attributes JavaDoc attributes)
58             throws org.xml.sax.SAXException JavaDoc
59   {
60     Stylesheet thisSheet = handler.getStylesheet();
61     WhitespaceInfoPaths paths = new WhitespaceInfoPaths(thisSheet);
62     setPropertiesFromAttributes(handler, rawName, attributes, paths);
63
64     Vector JavaDoc xpaths = paths.getElements();
65
66     for (int i = 0; i < xpaths.size(); i++)
67     {
68       WhiteSpaceInfo wsi = new WhiteSpaceInfo((XPath) xpaths.elementAt(i), false, thisSheet);
69       wsi.setUid(handler.nextUid());
70
71       thisSheet.setPreserveSpaces(wsi);
72     }
73     paths.clearElements();
74   }
75 }
76
Popular Tags