com.novell.xsl.parser
Class AttrDef

java.lang.Object
  extended bycom.novell.xsl.parser.AttrDef

public class AttrDef
extends Object

Helper class for StylesheetParser.

An instance of AttrDef defines an attribute. An array of these objects is used to describe attributes for XSLT elements.

Parse methods for XSLT elements use AttrDef.parseAttributes() to perform attribute parsing.


Field Summary
static int AVT_EXPR
          Attribute is an attribute-value-template.
static int CHAR
          Attribute is a single character.
static int ENUM
          Attribute is one of a set of allowed values.
static int EXPR
          Attribute is an arbitrary XPath Expression.
static int MODE
          Attribute is a Mode name.
static int NAME
          Attribute is a XML Name (a valid XML 1.0) name.
static int OPTIONAL
          Specifies attribute is optional.
static int PATTERN
          Attribute is a Pattern.
static int PRIORITY
          Attribute is a Priority.
static int QNAME
          Attribute is an XML QName (a valid XML Namespaces name).
static int REQUIRED
          Specifies attribute is required.
static int SELECT_EXPR
          Attribute is an expression returning a node-set.
static int STRING
          Attribute is an arbitrary String.
static int TOP_EXPR
          Attribute is a top-level expression that can't contain variable references.
static int TOP_PATTERN
          Attribute is a top-level Pattern.
 
Constructor Summary
AttrDef(String name, int optOrReq, int defaultValue, String[] legalValues)
          Construct an AttrDef for attributes of type ENUM.
AttrDef(String name, int optOrReq, Object defaultValue, int type)
          Construct an AttrDef for any attribute type other than ENUM.
 
Method Summary
 boolean isRequired()
          Return true if the attribute represented by this object is required.
static Object[] parseAttributes(StylesheetParser stylesheetParser, Element element, AttrDef[] desc)
          Parses the attributes of the passed element according to the specified array of AttrDef objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTIONAL

public static final int OPTIONAL
Specifies attribute is optional.

See Also:
Constant Field Values

REQUIRED

public static final int REQUIRED
Specifies attribute is required.

See Also:
Constant Field Values

AVT_EXPR

public static final int AVT_EXPR
Attribute is an attribute-value-template. Attribute value is returned as type com.novell.xml.xpath.Expression.

See Also:
Constant Field Values

ENUM

public static final int ENUM
Attribute is one of a set of allowed values. Attribute value is returned as type java.lang.Integer.

See Also:
Constant Field Values

TOP_PATTERN

public static final int TOP_PATTERN
Attribute is a top-level Pattern. Attribute value is returned as type com.novell.xsl.pattern.Pattern.

See Also:
Constant Field Values

PATTERN

public static final int PATTERN
Attribute is a Pattern. Attribute value is returned as type com.novell.xsl.pattern.Pattern.

See Also:
Constant Field Values

MODE

public static final int MODE
Attribute is a Mode name. Attribute value is returned as type com.novell.xsl.process.Mode.

See Also:
Constant Field Values

NAME

public static final int NAME
Attribute is a XML Name (a valid XML 1.0) name. Attribute value is returned as type java.lang.String.

See Also:
Constant Field Values

QNAME

public static final int QNAME
Attribute is an XML QName (a valid XML Namespaces name). Attribute value is returned as type com.novell.xml.util.ExpandedQName.

See Also:
Constant Field Values

PRIORITY

public static final int PRIORITY
Attribute is a Priority. Attribute value is returned as type com.novell.xsl.process.Priority.

See Also:
Constant Field Values

SELECT_EXPR

public static final int SELECT_EXPR
Attribute is an expression returning a node-set. Attribute value is returned as type com.novell.xml.xpath.Expression.

See Also:
Constant Field Values

STRING

public static final int STRING
Attribute is an arbitrary String. Attribute value is returned as type java.lang.String.

See Also:
Constant Field Values

TOP_EXPR

public static final int TOP_EXPR
Attribute is a top-level expression that can't contain variable references. Attribute value is returned as type com.novell.xml.xpath.Expression.

See Also:
Constant Field Values

EXPR

public static final int EXPR
Attribute is an arbitrary XPath Expression. Attribute value is returned as type com.novell.xml.xpath.Expression.

See Also:
Constant Field Values

CHAR

public static final int CHAR
Attribute is a single character. Attribute value is returned as type java.lang.Character.

See Also:
Constant Field Values
Constructor Detail

AttrDef

public AttrDef(String name,
               int optOrReq,
               Object defaultValue,
               int type)
Construct an AttrDef for any attribute type other than ENUM.

Parameters:
name - The name of the attribute (NOT a prefixed name).
optOrReq - AttrDef.OPTIONAL or AttrDef.REQUIRED.
defaultValue - The Object to return as the default value if the attribute doesn't appear on an element instance. This may be null.
type - The type of the attribute (AttrDef.AVT_EXPR, AttrDef.STRING, etc.)

AttrDef

public AttrDef(String name,
               int optOrReq,
               int defaultValue,
               String[] legalValues)
Construct an AttrDef for attributes of type ENUM.

Parameters:
name - The name of the attribute (NOT a prefixed name).
optOrReq - AttrDef.OPTIONAL or AttrDef.REQUIRED.
defaultValue - The index of the default value if the attribute doesn't appear on an element instance. This may be null.
legalValues - Array of String objects that define the allowed values for the attribute. The returned Integer object will correspond to the index of the actual value in this array.
Method Detail

isRequired

public boolean isRequired()
Return true if the attribute represented by this object is required.

Returns:
true if attribute is required.

parseAttributes

public static Object[] parseAttributes(StylesheetParser stylesheetParser,
                                       Element element,
                                       AttrDef[] desc)
                                throws XSLTParserException
Parses the attributes of the passed element according to the specified array of AttrDef objects.

Namespace declarations ("xmlns:prefix") are be ignored.

Namespace-qualified attributes are ignored (including xml:space and xml:lang).

Each attribute is parsed according to type and the resulting Object is placed in the returned Object array at the index corresponding to the AttrDef object in the passed desc array. See the type definitions for the actual object type (AttrDef.AVT_EXPR, AttrDef.ENUM, etc.).

Errors are reported via the StylesheetParser if an attribute appears that is not described in the passed AttrDef array (other than those that are ignored, see above), if an attribute has an invalid value, or if a REQUIRED attribute is missing. If an error occurs on an attribute, the resulting entry in the returned Object array will be null.

If an OPTIONAL attribute definition doesn't include a default value, then the attribute entry in the returned Object array will be null.

Parameters:
stylesheetParser - The stylesheet parser object that is used for parsing the XSLT document containing element.
element - The element from the XSLT document whose attributes are to be parsed.
desc - An array describing the element's attributes.
Returns:
An array containing the parsed attribute values.
Throws:
XSLTParserException - If the StylesheetParser error handler throws this exception when an error is reported.