org.apache.xalan.xsltc.compiler
Class Whitespace

java.lang.Object
  extended by org.apache.xalan.xsltc.compiler.SyntaxTreeNode
      extended by org.apache.xalan.xsltc.compiler.TopLevelElement
          extended by org.apache.xalan.xsltc.compiler.Whitespace
All Implemented Interfaces:
Constants

final class Whitespace
extends TopLevelElement


Nested Class Summary
private static class Whitespace.WhitespaceRule
          Auxillary class for encapsulating a single strip/preserve rule
 
Field Summary
private  int _action
           
private  java.lang.String _elementList
           
private  int _importPrecedence
           
static int PRESERVE_SPACE
           
static int RULE_ALL
           
static int RULE_ELEMENT
           
static int RULE_NAMESPACE
           
static int RULE_NONE
           
static int STRIP_SPACE
           
static int USE_PREDICATE
           
 
Fields inherited from class org.apache.xalan.xsltc.compiler.TopLevelElement
_dependencies
 
Fields inherited from class org.apache.xalan.xsltc.compiler.SyntaxTreeNode
_attributes, _parent, _qname, Dummy, IndentIncrement, UNKNOWN_STYLESHEET_NODE_ID
 
Fields inherited from interface org.apache.xalan.xsltc.compiler.Constants
ABSOLUTE_ITERATOR, ACC_FINAL, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_SUPER, ADD_ATTRIBUTE, ADD_ATTRIBUTE_SIG, ADD_ITERATOR, ADD_ITERATOR_SIG, ADD_PARAMETER, ADD_PARAMETER_SIG, APPLY_TEMPLATES, ATTR_SET_SIG, ATTRIBUTE_LIST_FIELD, ATTRIBUTE_LIST_IMPL_CLASS, ATTRIBUTE_LIST_IMPL_SIG, ATTRIBUTES_SIG, BASIS_LIBRARY_CLASS, BOOLEAN_CLASS, BOOLEAN_VALUE, BOOLEAN_VALUE_SIG, CACHED_NODE_LIST_ITERATOR_CLASS, CHARACTERS, CHARACTERS_SIG, CHARACTERSW, CHARACTERSW_SIG, CLEAR_ATTRIBUTES, CLEAR_ATTRIBUTES_SIG, COLLATOR_CLASS, COLLATOR_SIG, COMPILER_PACKAGE, CURRENT_NODE_LIST_FILTER, CURRENT_NODE_LIST_FILTER_SIG, CURRENT_NODE_LIST_ITERATOR, CURRENT_NODE_LIST_ITERATOR_SIG, DEFAULT_NODE_COUNTER, DEFAULT_NODE_COUNTER_SIG, DOCUMENT_PNAME, DOM_ADAPTER_CLASS, DOM_ADAPTER_SIG, DOM_FIELD, DOM_IMPL, DOM_IMPL_CLASS, DOM_IMPL_SIG, DOM_INTF, DOM_INTF_SIG, DOM_PNAME, DOUBLE_CLASS, DOUBLE_SIG, DOUBLE_VALUE, DOUBLE_VALUE_SIG, DUP_FILTERED_ITERATOR, EMPTYATTR_FIELD, EMPTYSTRING, ERROR, EXPAND_STYLESHEET_QNAME_REF, EXPAND_STYLESHEET_QNAME_SIG, FALLBACK_CLASS, FATAL, FILTER_INTERFACE, FILTER_INTERFACE_SIG, FILTER_ITERATOR, FILTER_STEP_ITERATOR, FORMAT_SYMBOLS_FIELD, GET_ATTRIBUTE_VALUE, GET_ATTRIBUTE_VALUE_SIG, GET_CHILDREN, GET_CHILDREN_SIG, GET_ELEMENT_VALUE, GET_ELEMENT_VALUE_SIG, GET_ITERATOR_SIG, GET_NODE_NAME, GET_NODE_NAME_SIG, GET_NODE_TYPE, GET_NODE_TYPE_SIG, GET_NODE_VALUE, GET_NODE_VALUE_ITERATOR, GET_NODE_VALUE_ITERATOR_SIG, GET_NODE_VALUE_SIG, GET_PARAMETER, GET_PARAMETER_SIG, GET_PARENT, GET_PARENT_SIG, GET_TYPED_CHILDREN, GET_TYPED_CHILDREN_SIG, GET_UNPARSED_ENTITY_URI, GET_UNPARSED_ENTITY_URI_SIG, HAS_ATTRIBUTE, HAS_ATTRIBUTE_SIG, HASIDCALL_INDEX, HASIDCALL_INDEX_SIG, INT_VALUE, INT_VALUE_SIG, INTEGER_CLASS, INTEGER_SIG, INTERNAL, INVOKE_METHOD, ITERATOR_FIELD_SIG, ITERATOR_PNAME, KEY_INDEX_CLASS, KEY_INDEX_ITERATOR_SIG, KEY_INDEX_SIG, LAST_INDEX, LOAD_DOCUMENT_CLASS, LOCALE_CLASS, LOCALE_SIG, LOOKUP_STYLESHEET_QNAME_NS_REF, LOOKUP_STYLESHEET_QNAME_NS_SIG, MAKE_NODE, MAKE_NODE_LIST, MAKE_NODE_LIST_SIG, MAKE_NODE_LIST_SIG2, MAKE_NODE_SIG, MAKE_NODE_SIG2, MATCHING_ITERATOR, MATH_CLASS, MULTI_DOM_CLASS, MULTI_DOM_SIG, NAMES_INDEX, NAMES_INDEX_SIG, NAMESPACE_FEATURE, NAMESPACE_INDEX, NAMESPACE_INDEX_SIG, NEXT, NEXT_SIG, NEXTID, NODE, NODE_COUNTER, NODE_COUNTER_SIG, NODE_FIELD, NODE_FIELD_SIG, NODE_ITERATOR, NODE_ITERATOR_BASE, NODE_ITERATOR_SIG, NODE_PNAME, NODE_SIG, NODE_SORT_FACTORY, NODE_SORT_FACTORY_SIG, NODE_SORT_RECORD, NODE_SORT_RECORD_SIG, NS_ANCESTORS_INDEX_SIG, NTH_ITERATOR_CLASS, OBJECT_CLASS, OBJECT_SIG, ORDER_ITERATOR, ORDER_ITERATOR_SIG, OUTPUT_BASE, OUTPUT_HANDLER, OUTPUT_HANDLER_SIG, POP_PARAM_FRAME, POP_PARAM_FRAME_SIG, POSITION_INDEX, PREFIX_URIS_ARRAY_SIG, PREFIX_URIS_IDX_SIG, PUSH_PARAM_FRAME, PUSH_PARAM_FRAME_SIG, REDIRECT_URI, RESET, RESET_SIG, RTF_INITIAL_SIZE, RUNTIME_NODE_CLASS, RUNTIME_PACKAGE, SAX_IMPL, SAX_IMPL_CLASS, SAX_IMPL_SIG, SET_START_NODE, SET_START_NODE_SIG, SINGLETON_ITERATOR, SORT_ITERATOR, SORT_ITERATOR_SIG, STATIC_CHAR_DATA_FIELD, STATIC_CHAR_DATA_FIELD_SIG, STATIC_NAMES_ARRAY_FIELD, STATIC_NAMESPACE_ARRAY_FIELD, STATIC_NS_ANCESTORS_ARRAY_FIELD, STATIC_PREFIX_URIS_ARRAY_FIELD, STATIC_PREFIX_URIS_IDX_ARRAY_FIELD, STATIC_TYPES_ARRAY_FIELD, STATIC_URIS_ARRAY_FIELD, STEP_ITERATOR_CLASS, STREAM_XML_OUTPUT, STRING, STRING_BUFFER_CLASS, STRING_BUFFER_SIG, STRING_CLASS, STRING_SIG, STRING_TO_INT, STRING_TO_INT_SIG, STRING_TO_REAL, STRING_TO_REAL_SIG, STRING_VALUE_HANDLER, STRING_VALUE_HANDLER_SIG, STRING_WRITER, STRIP_SPACE_INTF, STRIP_SPACE_PARAMS, STRIP_SPACE_SIG, TRANSLET_CLASS, TRANSLET_FIELD, TRANSLET_FIELD_SIG, TRANSLET_INTF, TRANSLET_INTF_SIG, TRANSLET_OUTPUT_BASE, TRANSLET_OUTPUT_INTERFACE, TRANSLET_OUTPUT_PNAME, TRANSLET_OUTPUT_SIG, TRANSLET_PNAME, TRANSLET_SIG, TRANSLET_URI, TRANSLET_VERSION_INDEX, TRANSLET_VERSION_INDEX_SIG, TYPES_INDEX, TYPES_INDEX_SIG, UNION_ITERATOR_CLASS, UNION_ITERATOR_SIG, UNSUPPORTED, URIS_INDEX, URIS_INDEX_SIG, WARNING, WRITER_SIG, XHTML_URI, XMLNS_PREFIX, XMLNS_STRING, XMLNS_URI, XSLT_PACKAGE, XSLT_URI
 
Constructor Summary
Whitespace()
           
 
Method Summary
private static void compileDefault(int defaultAction, ClassGenerator classGen)
          Compiles the predicate method
private static void compilePredicate(java.util.Vector rules, int defaultAction, ClassGenerator classGen)
          Compiles the predicate method
static void compilePreserveSpace(BranchHandle[] preserve, int pCount, InstructionList il)
           
static void compileStripSpace(BranchHandle[] strip, int sCount, InstructionList il)
           
private static Whitespace.WhitespaceRule findContradictingRule(java.util.Vector rules, Whitespace.WhitespaceRule rule)
          Scans through the rules vector and looks for a rule of higher priority that contradicts the current rule.
 java.util.Vector getRules()
          De-tokenize the elements listed in the 'elements' attribute and instanciate a set of strip/preserve rules.
 void parseContents(Parser parser)
          Parse the attributes of the xsl:strip/preserve-space element.
private static int partition(java.util.Vector rules, int p, int r)
          Used with quicksort method above
private static int prioritizeRules(java.util.Vector rules)
          Orders a set or rules by priority, removes redundant rules and rules that are shadowed by stronger, contradicting rules.
private static void quicksort(java.util.Vector rules, int p, int r)
          Sorts a range of rules with regard to PRIORITY only
 void translate(ClassGenerator classGen, MethodGenerator methodGen)
          This method should not produce any code
static int translateRules(java.util.Vector rules, ClassGenerator classGen)
          Takes a vector of WhitespaceRule objects and generates a predicate method.
 Type typeCheck(SymbolTable stable)
          Type-check contents/attributes - nothing to do...
 
Methods inherited from class org.apache.xalan.xsltc.compiler.TopLevelElement
addDependency, compile, display, getDependencies
 
Methods inherited from class org.apache.xalan.xsltc.compiler.SyntaxTreeNode
addAttribute, addElement, addPrefixMapping, compileResultTree, contextDependent, dependentContents, displayContents, elementAt, elementCount, elements, getAttribute, getAttribute, getAttributes, getContents, getImportPrecedence, getLineNumber, getNodeIDForStylesheetNSLookup, getParent, getParser, getPrefixMapping, getQName, getStylesheet, getSymbolTable, getTemplate, getXSLTC, hasAttribute, hasContents, indent, isDummy, lastChild, lookupNamespace, lookupPrefix, parseChildren, removeElement, reportError, reportWarning, setAttributes, setFirstElement, setLineNumber, setParent, setParser, setPrefixMapping, setQName, setQName, translateContents, typeCheckContents, updateScope
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_PREDICATE

public static final int USE_PREDICATE
See Also:
Constant Field Values

STRIP_SPACE

public static final int STRIP_SPACE
See Also:
Constant Field Values

PRESERVE_SPACE

public static final int PRESERVE_SPACE
See Also:
Constant Field Values

RULE_NONE

public static final int RULE_NONE
See Also:
Constant Field Values

RULE_ELEMENT

public static final int RULE_ELEMENT
See Also:
Constant Field Values

RULE_NAMESPACE

public static final int RULE_NAMESPACE
See Also:
Constant Field Values

RULE_ALL

public static final int RULE_ALL
See Also:
Constant Field Values

_elementList

private java.lang.String _elementList

_action

private int _action

_importPrecedence

private int _importPrecedence
Constructor Detail

Whitespace

Whitespace()
Method Detail

parseContents

public void parseContents(Parser parser)
Parse the attributes of the xsl:strip/preserve-space element. The element should have not contents (ignored if any).

Overrides:
parseContents in class SyntaxTreeNode
Parameters:
parser - reference to the XSLT parser

getRules

public java.util.Vector getRules()
De-tokenize the elements listed in the 'elements' attribute and instanciate a set of strip/preserve rules.


findContradictingRule

private static Whitespace.WhitespaceRule findContradictingRule(java.util.Vector rules,
                                                               Whitespace.WhitespaceRule rule)
Scans through the rules vector and looks for a rule of higher priority that contradicts the current rule.


prioritizeRules

private static int prioritizeRules(java.util.Vector rules)
Orders a set or rules by priority, removes redundant rules and rules that are shadowed by stronger, contradicting rules.


compileStripSpace

public static void compileStripSpace(BranchHandle[] strip,
                                     int sCount,
                                     InstructionList il)

compilePreserveSpace

public static void compilePreserveSpace(BranchHandle[] preserve,
                                        int pCount,
                                        InstructionList il)

compilePredicate

private static void compilePredicate(java.util.Vector rules,
                                     int defaultAction,
                                     ClassGenerator classGen)
Compiles the predicate method


compileDefault

private static void compileDefault(int defaultAction,
                                   ClassGenerator classGen)
Compiles the predicate method


translateRules

public static int translateRules(java.util.Vector rules,
                                 ClassGenerator classGen)
Takes a vector of WhitespaceRule objects and generates a predicate method. This method returns the translets default action for handling whitespace text-nodes: - USE_PREDICATE (run the method generated by this method) - STRIP_SPACE (always strip whitespace text-nodes) - PRESERVE_SPACE (always preserve whitespace text-nodes)


quicksort

private static void quicksort(java.util.Vector rules,
                              int p,
                              int r)
Sorts a range of rules with regard to PRIORITY only


partition

private static int partition(java.util.Vector rules,
                             int p,
                             int r)
Used with quicksort method above


typeCheck

public Type typeCheck(SymbolTable stable)
               throws TypeCheckError
Type-check contents/attributes - nothing to do...

Overrides:
typeCheck in class TopLevelElement
Parameters:
stable - The compiler/parser's symbol table
Throws:
TypeCheckError

translate

public void translate(ClassGenerator classGen,
                      MethodGenerator methodGen)
This method should not produce any code

Overrides:
translate in class TopLevelElement
Parameters:
classGen - BCEL Java class generator
methodGen - BCEL Java method generator