KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > StylesheetStripper


1 package com.icl.saxon;
2 import com.icl.saxon.om.*;
3 import com.icl.saxon.expr.*;
4 import com.icl.saxon.output.ProxyEmitter;
5 import com.icl.saxon.pattern.*;
6 import com.icl.saxon.tree.ElementImpl;
7
8 import org.xml.sax.Attributes JavaDoc;
9
10 import javax.xml.transform.TransformerException JavaDoc;
11
12
13 /**
14   * The StylesheetStripper refines the Stripper class to do stripping of
15   * whitespace nodes on a stylesheet. This is handled specially (a) because
16   * it is done at compile time, so there is no Controller or Context available, and (b)
17   * because the rules are very simple
18   * @author Michael H. Kay (mhkay@iclway.co.uk)
19   */

20   
21 public class StylesheetStripper extends Stripper
22 {
23
24     int xsl_text; // fingerprint of name "xsl:text"
25

26     /**
27     * Set the rules appropriate for whitespace-stripping in a stylesheet
28     */

29     
30     public void setStylesheetRules(NamePool namePool) {
31         xsl_text = namePool.getFingerprint(Namespace.XSLT, "text");
32     }
33     
34     /**
35     * Decide whether an element is in the set of white-space preserving element types
36     * @param uri The namespace URI of the element name
37     * @param localname The local part of the element name
38     * @return true if the element is in the set of white-space preserving element types
39     */

40
41     public boolean isSpacePreserving(int nameCode) {
42         return (nameCode & 0xfffff) == xsl_text;
43     }
44
45
46 } // end of class StylesheetStripper
47

48 //
49
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
50
// you may not use this file except in compliance with the License. You may obtain a copy of the
51
// License at http://www.mozilla.org/MPL/
52
//
53
// Software distributed under the License is distributed on an "AS IS" basis,
54
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
55
// See the License for the specific language governing rights and limitations under the License.
56
//
57
// The Original Code is: all this file.
58
//
59
// The Initial Developer of the Original Code is
60
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
61
//
62
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
63
//
64
// Contributor(s): none.
65
//
66
Popular Tags