Xvcl And Property Tag
CjOS Project @ cjos.sourceforge.net
Index
Bind Pages
Cjos Library
Cjos Pages
Cjos News Pages
Eric Pages
Introduction To Smart Api
Osgi Pages
Registry Api Pages
Smart Api Pages
Xvcl Pages
CjOS Project
Summary Page
Mailing List
Download
CVS
JOS Technical Edition
Support This Project
Xvcl Pages; [ Cjos Audience]

Overview

About this document

This document proposes a new property tag. This tag behaves just like the set tag, but follows the model of the input tag in HTML and the property tag in Apache Ant.

This is a proposal for a change in the XVCL specification. It was written by Gilbert Herschberger (30 September 2005).

Note: Modifying the DTD. Add the property tag to the dtd/xvcl.dtd document.

Details

 <property name="n" value="v"/>

is equivalent to

 <set var="n" value="v"/>

Goal

Explore the mechanism to extend the XVCL processor with custom tags.

Apache Ant provides a mechanism to extend a script with custom tags. The taskdef tag defines a custom tag. The mechanism is fully supported and encouraged and documented.

The XVCL processor has a mechanism to define tags. Tags are not defined in Java source code, but an external resource. It might be possible to add a tag to the XVCL processor by modifying this resource.

Contents

This document contains the following sections:

  • Section A - Defining the set Tag
  • Section B - Defining the property Tag


Section A - Defining the set Tag

Introduction

This section describes how the var tag is defined.

Mechanism

The following mechanism defines a tag, using the set tag as an example.

  1. A set tag corresponds to a Java class.
  2. A list of tags is maintained in an external resource.
  3. The XVCL processor parses a frame.
  4. The XVCL processor handles the parsed frame.

External resource

A list of tags is maintained in an external resource.

 package-name.config.properties

Defining

Here is how a tag is associated with a Java class.

 ####set Command
 set=package-name.SetVar
 SetVar_var=var
 SetVar_value=value
 SetVar_defer-evaluation=defer-evaluation

Java class

The set tag is associated with the SetVar class. A tag corresponds to a Java class. The class must be compiled and must be available on the Java classpath.

Parsing

A tag is part of an element. When parsing an XML-based frame with JDOM, an element becomes an instance of org.jdom.Element.

When parsing with MyBuilder, an element becomes an instance of XVCLNode. Therefore, a custom tag must extend XVCLNode.

For the set tag,

  • The SetVar class extends XVCLNode.
  1. XVCLNode extends MyElement.
  2. MyElement extends Element.

Attributes

The default attributes of a set tag are

  • var
  • value
  • defer-evaluation

An attribute name is mapped. The getAttributeExternalName() method implements the map from a constant internal name to a configure-able external name.

Using the default configuration, getAttributeExternalName( "SetVar_var" ) returns "var".


Section B - Defining the property Tag

Introduction

This section describes how to implement the proposed change in the XVCL specification.

Defining

Here is how a property tag is associated with a Java class.

 ####property Command
 set=package-name.Property
 Property_var=name
 Property_value=value
 Property_defer-evaluation=defer-evaluation

Alternative 1

The SetVar and Property classes share common code. Let's say that Property extends SetVar.

The parseAttributes() method should be the same except:

  • SetVar_ becomes Property_
  • var becomes name

Case study

This is a case study in the intent and purpose of the XVCL processor.

Source code shared by SetVar and Property is written into a frame called setvar-parseattributes.xml and re-used by setvar.xml and property.xml. The classname variable is defined, giving

  • classname_var,
  • classname_value, and
  • classname_defer-evaluation.

Inside setvar-parseattributes.xml, the <value-of> tag emits the "?@classname?" expression.