Package org.exolab.adaptx.xslt
Class XSLObject
- java.lang.Object
-
- org.exolab.adaptx.xslt.XSLObject
-
- Direct Known Subclasses:
AttributeSet,CopyOf,EmptyXSLObject,Selection,TemplateRule,Variable,XSLCallTemplate,XSLIf,XSLImport,XSLNumber,XSLOtherwise,XSLOutput,XSLSort,XSLText,XSLTStylesheet
public class XSLObject extends java.lang.ObjectThis 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
Fields Modifier and Type Field Description static shortAPPLY_IMPORTSstatic shortAPPLY_TEMPLATESstatic shortARGstatic shortATTRIBUTEstatic shortATTRIBUTE_SETstatic shortCALL_TEMPLATEstatic shortCDATAstatic shortCHOOSEstatic shortCOMMENTstatic shortCONTENTSstatic shortCOPYstatic shortCOPY_OFstatic shortELEMENTstatic shortENTITY_REFstatic shortFOR_EACHstatic shortFUNCTIONSstatic shortIDstatic shortIFstatic shortIMPORTstatic shortINCLUDEstatic shortKEYstatic shortLITERALstatic shortLOCALEstatic shortMESSAGEstatic shortNUMBERstatic shortOTHERWISEstatic shortOUTPUTstatic shortPARAMstatic shortPIstatic shortPRESERVE_SPACEstatic shortSCRIPTstatic shortSORTstatic shortSTRIP_SPACEstatic shortSTYLESHEETstatic shortTEMPLATEstatic shortTEXTstatic shortVALUE_OFstatic shortVARIABLEstatic shortWHENstatic shortWITH_PARAM
-
Constructor Summary
Constructors Constructor Description XSLObject(short type)Creates an XSLObject using the specified type
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNamespaceDecl(java.lang.String prefix, java.lang.String namespace)Adds the Given namespace declaration to this XSLObject's set of namespace declarationsbooleanappendAction(XSLObject xslObject)Appends the given XSLObject to this XSLObject's list of actions.voidappendText(char[] chars, int start, int length)Appends the text to this XSLObject.voidappendText(java.lang.String text)Appends the text to this XSLObject.ActionTemplategetActions()Returns the list of actions for this XSLObjectjava.lang.StringgetAttribute(java.lang.String name)Returns the value of the attribute whose name is equal to the given name.org.xml.sax.AttributeListgetAttributes()Returns the value of the specified attribute as an AttributeValueTemplatejava.lang.StringgetNamespace()Returns this XSLObject's namespace URI.XSLObjectgetNearestAncestor(short type)Returns the nearest ancestor of this XSLObject that is of the given type.static java.lang.StringgetNodeValue(org.w3c.dom.Node node)Returns the String value of a DOM Node.XSLTStylesheetgetStylesheet()Returns the XSLStylesheet which contains this XSLObjectstatic java.lang.StringgetText(org.w3c.dom.Element element)Retrieves the text of an ElementshortgetType()Returns the type of XSLObject this Object representsstatic shortgetTypeFromName(java.lang.String name)Returns the type of XSL Object that has the given namejava.lang.StringgetTypeName()Returns the name of this XSLObjectjava.lang.StringresolveNamespace(java.lang.String prefix)voidsetAllowActions(boolean allow)voidsetAttribute(java.lang.String name, java.lang.String value)Sets the attribute with the given name to the given value.voidsetNamespace(java.lang.String uri)Sets this XSLObject's namespace URIvoidsetTypeName(java.lang.String name)
-
-
-
Field Detail
-
APPLY_IMPORTS
public static final short APPLY_IMPORTS
- See Also:
- Constant Field Values
-
APPLY_TEMPLATES
public static final short APPLY_TEMPLATES
- See Also:
- Constant Field Values
-
ARG
public static final short ARG
- See Also:
- Constant Field Values
-
ATTRIBUTE
public static final short ATTRIBUTE
- See Also:
- Constant Field Values
-
ATTRIBUTE_SET
public static final short ATTRIBUTE_SET
- See Also:
- Constant Field Values
-
CALL_TEMPLATE
public static final short CALL_TEMPLATE
- See Also:
- Constant Field Values
-
CDATA
public static final short CDATA
- See Also:
- Constant Field Values
-
CHOOSE
public static final short CHOOSE
- See Also:
- Constant Field Values
-
COMMENT
public static final short COMMENT
- See Also:
- Constant Field Values
-
CONTENTS
public static final short CONTENTS
- See Also:
- Constant Field Values
-
COPY
public static final short COPY
- See Also:
- Constant Field Values
-
COPY_OF
public static final short COPY_OF
- See Also:
- Constant Field Values
-
ELEMENT
public static final short ELEMENT
- See Also:
- Constant Field Values
-
FOR_EACH
public static final short FOR_EACH
- See Also:
- Constant Field Values
-
FUNCTIONS
public static final short FUNCTIONS
- See Also:
- Constant Field Values
-
ID
public static final short ID
- See Also:
- Constant Field Values
-
IF
public static final short IF
- See Also:
- Constant Field Values
-
IMPORT
public static final short IMPORT
- See Also:
- Constant Field Values
-
INCLUDE
public static final short INCLUDE
- See Also:
- Constant Field Values
-
KEY
public static final short KEY
- See Also:
- Constant Field Values
-
LITERAL
public static final short LITERAL
- See Also:
- Constant Field Values
-
LOCALE
public static final short LOCALE
- See Also:
- Constant Field Values
-
MESSAGE
public static final short MESSAGE
- See Also:
- Constant Field Values
-
NUMBER
public static final short NUMBER
- See Also:
- Constant Field Values
-
OTHERWISE
public static final short OTHERWISE
- See Also:
- Constant Field Values
-
OUTPUT
public static final short OUTPUT
- See Also:
- Constant Field Values
-
PARAM
public static final short PARAM
- See Also:
- Constant Field Values
-
PI
public static final short PI
- See Also:
- Constant Field Values
-
PRESERVE_SPACE
public static final short PRESERVE_SPACE
- See Also:
- Constant Field Values
-
SORT
public static final short SORT
- See Also:
- Constant Field Values
-
STRIP_SPACE
public static final short STRIP_SPACE
- See Also:
- Constant Field Values
-
STYLESHEET
public static final short STYLESHEET
- See Also:
- Constant Field Values
-
TEMPLATE
public static final short TEMPLATE
- See Also:
- Constant Field Values
-
TEXT
public static final short TEXT
- See Also:
- Constant Field Values
-
VALUE_OF
public static final short VALUE_OF
- See Also:
- Constant Field Values
-
VARIABLE
public static final short VARIABLE
- See Also:
- Constant Field Values
-
WHEN
public static final short WHEN
- See Also:
- Constant Field Values
-
WITH_PARAM
public static final short WITH_PARAM
- See Also:
- Constant Field Values
-
ENTITY_REF
public static final short ENTITY_REF
- See Also:
- Constant Field Values
-
SCRIPT
public static final short SCRIPT
- See Also:
- Constant Field Values
-
-
Method Detail
-
addNamespaceDecl
public void addNamespaceDecl(java.lang.String prefix, java.lang.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(java.lang.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:
text- the text to append
-
getActions
public ActionTemplate getActions()
Returns the list of actions for this XSLObject- Returns:
- the list of actions for this XSLObject
-
getAttribute
public java.lang.String getAttribute(java.lang.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 org.xml.sax.AttributeList getAttributes()
Returns the value of the specified attribute as an AttributeValueTemplate- Returns:
- the value of the specified attribute as an AttributeValueTemplate
- Throws:
XSLException- when the Attribute is not a valid AttrubueValueTemplate public AttributeValueTemplate getAttributeAsAVT(String name) throws XSLException { if (name == null) return null; String attValue = getAttribute(name); AttributeValueTemplate avt = null; if ((attValue != null) && (attValue.length() > 0)) { // look in cache first avt = (AttributeValueTemplate) avtCache.get(attValue); if (avt == null) { try { avt = new AttributeValueTemplate(attValue); // add to cache for performace // Do we need to clean cache? Yes if we are reusing // XSLObjects. No if not. I am currently not // reusing XSLObjects so I am not doing any house // cleaning. This could lead to memory problems if // XSLObjects are reused heavily. avtCache.put(attValue, avt); } catch(InvalidExprException iee) { throw new XSLException (XSLException.INVALID_ATTRIBUTE_VALUE_TEMPLATE, iee.getMessage()); } } } return avt; } //-- getAttributeAsAVT /** Returns the AttributeList for this XSLObject
-
getNamespace
public java.lang.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 java.lang.String getNodeValue(org.w3c.dom.Node node)
Returns the String value of a DOM Node.- Returns:
- the String value of a DOM Node.
- See Also:
Node
-
getStylesheet
public XSLTStylesheet getStylesheet()
Returns the XSLStylesheet which contains this XSLObject- Returns:
- the XSLStylesheet which contains this XSLObject
-
getText
public static java.lang.String getText(org.w3c.dom.Element element)
Retrieves the text of an Element- Returns:
- the text of the given Element
- See Also:
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(java.lang.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 java.lang.String getTypeName()
Returns the name of this XSLObject- Returns:
- the name of this XSLObject
-
resolveNamespace
public java.lang.String resolveNamespace(java.lang.String prefix)
-
setAllowActions
public void setAllowActions(boolean allow)
-
setTypeName
public void setTypeName(java.lang.String name)
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value) throws XSLExceptionSets the attribute with the given name to the given value.- Parameters:
name- the name of the attribute to setvalue- 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(java.lang.String uri)
Sets this XSLObject's namespace URI- Parameters:
uri- the namespace URI
-
-