org.exolab.adaptx.xslt

Class XSLObject

Known Direct Subclasses:
AttributeSet, CopyOf, EmptyXSLObject, Selection, TemplateRule, Variable, XSLCallTemplate, XSLIf, XSLImport, XSLNumber, XSLOtherwise, XSLOutput, XSLSort, XSLText, XSLTStylesheet

public class XSLObject
extends java.lang.Object

This class represents an XSLObject in the style tree. It is the most basic of all XSLObjects and contains common functionality across different XSLObjects. I originally had this implemented as an extended W3C DOM XML Element, but due to problems with extending different implementations, and to make it more cross-DOM accessible I've chosen an this approach. Since this once was a DOM Element, you will notice many of the methods are very DOM-like.
Version:
$Revision: 3934 $ $Date: 2003-10-02 11:58:30 +0200 (Thu, 02 Oct 2003) $
Author:
Keith Visco

Field Summary

static short
APPLY_IMPORTS
static short
APPLY_TEMPLATES
static short
ARG
static short
ATTRIBUTE
static short
ATTRIBUTE_SET
static short
CALL_TEMPLATE
static short
CDATA
static short
CHOOSE
static short
COMMENT
static short
CONTENTS
static short
COPY
static short
COPY_OF
static short
ELEMENT
static short
ENTITY_REF
static short
FOR_EACH
static short
FUNCTIONS
static short
ID
static short
IF
static short
IMPORT
static short
INCLUDE
static short
KEY
static short
LITERAL
static short
LOCALE
static short
MESSAGE
static short
NUMBER
static short
OTHERWISE
static short
OUTPUT
static short
PARAM
static short
PI
static short
PRESERVE_SPACE
static short
SCRIPT
static short
SORT
static short
STRIP_SPACE
static short
STYLESHEET
static short
TEMPLATE
static short
TEXT
static short
VALUE_OF
static short
VARIABLE
static short
WHEN
static short
WITH_PARAM

Constructor Summary

XSLObject(short type)
Creates an XSLObject using the specified type

Method Summary

void
addNamespaceDecl(String prefix, String namespace)
Adds the Given namespace declaration to this XSLObject's set of namespace declarations
boolean
appendAction(XSLObject xslObject)
Appends the given XSLObject to this XSLObject's list of actions.
void
appendText(String text)
Appends the text to this XSLObject.
void
appendText(char[] chars, int start, int length)
Appends the text to this XSLObject.
ActionTemplate
getActions()
Returns the list of actions for this XSLObject
String
getAttribute(String name)
Returns the value of the attribute whose name is equal to the given name.
AttributeList
getAttributes()
Returns the value of the specified attribute as an AttributeValueTemplate
String
getNamespace()
Returns this XSLObject's namespace URI.
XSLObject
getNearestAncestor(short type)
Returns the nearest ancestor of this XSLObject that is of the given type.
static String
getNodeValue(Node node)
Returns the String value of a DOM Node.
XSLTStylesheet
getStylesheet()
Returns the XSLStylesheet which contains this XSLObject
static String
getText(Element element)
Retrieves the text of an Element
short
getType()
Returns the type of XSLObject this Object represents
static short
getTypeFromName(String name)
Returns the type of XSL Object that has the given name
String
getTypeName()
Returns the name of this XSLObject
String
resolveNamespace(String prefix)
void
setAllowActions(boolean allow)
void
setAttribute(String name, String value)
Sets the attribute with the given name to the given value.
void
setNamespace(String uri)
Sets this XSLObject's namespace URI
void
setTypeName(String name)

Field Details

APPLY_IMPORTS

public static final short APPLY_IMPORTS
Field Value:
0

APPLY_TEMPLATES

public static final short APPLY_TEMPLATES
Field Value:
1

ARG

public static final short ARG
Field Value:
2

ATTRIBUTE

public static final short ATTRIBUTE
Field Value:
3

ATTRIBUTE_SET

public static final short ATTRIBUTE_SET
Field Value:
4

CALL_TEMPLATE

public static final short CALL_TEMPLATE
Field Value:
5

CDATA

public static final short CDATA
Field Value:
6

CHOOSE

public static final short CHOOSE
Field Value:
7

COMMENT

public static final short COMMENT
Field Value:
8

CONTENTS

public static final short CONTENTS
Field Value:
9

COPY

public static final short COPY
Field Value:
10

COPY_OF

public static final short COPY_OF
Field Value:
11

ELEMENT

public static final short ELEMENT
Field Value:
12

ENTITY_REF

public static final short ENTITY_REF
Field Value:
38

FOR_EACH

public static final short FOR_EACH
Field Value:
13

FUNCTIONS

public static final short FUNCTIONS
Field Value:
14

ID

public static final short ID
Field Value:
15

IF

public static final short IF
Field Value:
16

IMPORT

public static final short IMPORT
Field Value:
17

INCLUDE

public static final short INCLUDE
Field Value:
18

KEY

public static final short KEY
Field Value:
19

LITERAL

public static final short LITERAL
Field Value:
20

LOCALE

public static final short LOCALE
Field Value:
21

MESSAGE

public static final short MESSAGE
Field Value:
22

NUMBER

public static final short NUMBER
Field Value:
23

OTHERWISE

public static final short OTHERWISE
Field Value:
24

OUTPUT

public static final short OUTPUT
Field Value:
25

PARAM

public static final short PARAM
Field Value:
26

PI

public static final short PI
Field Value:
27

PRESERVE_SPACE

public static final short PRESERVE_SPACE
Field Value:
28

SCRIPT

public static final short SCRIPT
Field Value:
39

SORT

public static final short SORT
Field Value:
29

STRIP_SPACE

public static final short STRIP_SPACE
Field Value:
30

STYLESHEET

public static final short STYLESHEET
Field Value:
31

TEMPLATE

public static final short TEMPLATE
Field Value:
32

TEXT

public static final short TEXT
Field Value:
33

VALUE_OF

public static final short VALUE_OF
Field Value:
34

VARIABLE

public static final short VARIABLE
Field Value:
35

WHEN

public static final short WHEN
Field Value:
36

WITH_PARAM

public static final short WITH_PARAM
Field Value:
37

Constructor Details

XSLObject

public XSLObject(short type)
Creates an XSLObject using the specified type
Parameters:
type - the type of XSLObject that the new instance represents

Method Details

addNamespaceDecl

public void addNamespaceDecl(String prefix,
                             String namespace)
Adds the Given namespace declaration to this XSLObject's set of namespace declarations

appendAction

public boolean appendAction(XSLObject xslObject)
Appends the given XSLObject to this XSLObject's list of actions.
Parameters:
xslObject - the XSLObject to add to this XSLObject's list of actions
Returns:
true if the given XSLObject has been added to this XSLObject otherwise false

appendText

public void appendText(String text)
Appends the text to this XSLObject. This is slightly more efficient than using appendAction(new XSLText(text)) if the last child is already an XSLText object. Otherwise there is no difference.
Parameters:
text - the text to append

appendText

public void appendText(char[] chars,
                       int start,
                       int length)
Appends the text to this XSLObject. This is slightly more efficient than using appendAction(new XSLText(text)) if the last child is already an XSLText object. Otherwise there is no difference.
Parameters:

getActions

public ActionTemplate getActions()
Returns the list of actions for this XSLObject
Returns:
the list of actions for this XSLObject

getAttribute

public String getAttribute(String name)
Returns the value of the attribute whose name is equal to the given name.
Returns:
the value of the attribute whose name is equal to the given name or null if no attribute exist's with such a name.

getAttributes

public AttributeList getAttributes()
Returns the value of the specified attribute as an AttributeValueTemplate
Returns:
the value of the specified attribute as an AttributeValueTemplate

getNamespace

public String getNamespace()
Returns this XSLObject's namespace URI.
Returns:
the namespace URI or null if none exists.

getNearestAncestor

public XSLObject getNearestAncestor(short type)
Returns the nearest ancestor of this XSLObject that is of the given type.
Parameters:
type - the type of ancestor to search for
Returns:
the nearest ancestor of this XSLObject that is of the given type.

getNodeValue

public static String getNodeValue(Node node)
Returns the String value of a DOM Node.
Returns:
the String value of a DOM Node.
See Also:
org.w3c.dom.Node

getStylesheet

public XSLTStylesheet getStylesheet()
Returns the XSLStylesheet which contains this XSLObject
Returns:
the XSLStylesheet which contains this XSLObject

getText

public static String getText(Element element)
Retrieves the text of an Element
Returns:
the text of the given Element
See Also:
org.w3c.dom.Element

getType

public final short getType()
Returns the type of XSLObject this Object represents
Returns:
the type of XSLObject that this Object represents

getTypeFromName

public static short getTypeFromName(String name)
Returns the type of XSL Object that has the given name
Parameters:
name - the name the XSLObject
Returns:
the type of XSL Object that has the given name

getTypeName

public String getTypeName()
Returns the name of this XSLObject
Returns:
the name of this XSLObject

resolveNamespace

public String resolveNamespace(String prefix)

setAllowActions

public void setAllowActions(boolean allow)

setAttribute

public void setAttribute(String name,
                         String value)
            throws XSLException
Sets the attribute with the given name to the given value.
Parameters:
name - the name of the attribute to set
value - the value to set the attribute to
Throws:
XSLException - if this XSLObject does not allow attributes with the given name, or if the attribute is read only

setNamespace

public void setNamespace(String uri)
Sets this XSLObject's namespace URI
Parameters:
uri - the namespace URI

setTypeName

public void setTypeName(String name)