sunlabs.brazil.sunlabs
Class ScanTemplate

java.lang.Object
  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.sunlabs.ScanTemplate (view source)
All Implemented Interfaces:
TemplateInterface

public class ScanTemplate
extends Template

Template for managing ScanHTML things: a tree representation of an *ml file based on a supplied list of tags.

<scancreate id="scan_name" src="markup_to_scan" tags="tags_to_scan" />
Scan an html document and locate all the specified tags. The "id" names the scan, wich can be manipulated by the other <scan... > tags. The "tags" are a space delimited list of tags to scan for.
<scandelete id=name.node />
Remove a portion of an html document
<scancombine id=name.node attribute=xxx value=xxx>
edit an attribute of a "tag" or the value of non-tag data.


Field Summary
 
Fields inherited from class sunlabs.brazil.template.Template
debug
 
Constructor Summary
ScanTemplate()
           
 
Method Summary
 boolean done(RewriteContext hr)
          Called after all tags have been processed, one final chance.
 void tag_scancombine(RewriteContext hr)
          Add one scan onto another.
 void tag_scancreate(RewriteContext hr)
          Create a "scan" object.
 void tag_scandelete(RewriteContext hr)
          Delete a portion of a scan.
 void tag_scanedit(RewriteContext hr)
          Edit some portion of the scan insitu.
 void tag_set(RewriteContext hr)
          Steal the "set" tag away from the SetTemplate for my id prefixs! This is an experiment.
 
Methods inherited from class sunlabs.brazil.template.Template
init
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScanTemplate

public ScanTemplate()
Method Detail

done

public boolean done(RewriteContext hr)
Description copied from class: Template
Called after all tags have been processed, one final chance.

Specified by:
done in interface TemplateInterface
Overrides:
done in class Template

tag_scancreate

public void tag_scancreate(RewriteContext hr)
Create a "scan" object.
id: the name of the object
src: The markup to scan
tags: The (whitespace delimited) tags to parse on.

The various nodes and attributes of the tree may be obtained using properties (e.g. ${name.node.value}) to view various portions of the tree. The "name" is the scan id, the "node" is the numerical node identifier (if required) and the "value" specifies how to represent the node as a String.

"value" can be one of the following. If the value doesn't make sense, such as asking for the "tag" value of a String, the entire variable is undefined.

All representations that return a node name, or list of node names use a form suitable for use as the "node" part of a property, relative to the supplied "node" name.

A limited set of changes may be made to the scan using:

  • <set name=scan.node.keyword namespace=scan value="new value">
    scan
    is the name of the scan
    node
    is a node name (e.g. 1.3.2)
    keyword
    , for non-tags is "value", "append", or "prepend"
    keyword
    , for tags is "attribute".name, where "name" names the attribute to set. For this to work, this template must be placed in front of the SetTemplate (if used) in the template list. If the namespace doesn't match the template prefix, then <set ...> is delegated to the SetTemplate() for normal processing.
    tag
    The name of the tag
    token
    The entire token value
    childCount
    The number of direct child nodes.
    children
    The white-space delimited list of direct child nodes (e.g. "1 2 3 ... childCount-1)
    markup
    all markup from this node
    attribute.[X]
    value of attribute "X"
    attributes
    white-space delimited list of attribute names
    tokens
    list of all token names for this tree.
    tags
    list of all tokens that are tags
    tags.[xx]
    list of all tags of tpe [xx]
    notags
    list of all non-tag tokens
    glob[.pattern]
    list of all token names whose values contain the glob [pattern]
    globfirst
    globlast
    the first/last token in glob.[pattern]
    match.[attribute]=[glob]
    list of nodes whose for which the specified attribute matches the [glob] pattern.
    matchfirst
    matchlast
    the first/last match (see above)


  • tag_scandelete

    public void tag_scandelete(RewriteContext hr)
    Delete a portion of a scan.
    id: the scan do delete from
    node: the node to remove


    tag_scancombine

    public void tag_scancombine(RewriteContext hr)
    Add one scan onto another.
    id.node: the scan to add to
    insert: the name of the "other" scan to add to this one.
    src: plain text source in lieu of "insert"
    at=before|after,[child]: where to insert "other"
    - after: (default) sibling, after
    - before sibling, before
    - child as child, otherwise make sibling

    Notes:


    tag_scanedit

    public void tag_scanedit(RewriteContext hr)
    Edit some portion of the scan insitu. For nodes which are tags, only attributes may be editted, and "attribute" must be specified. If no value is specified, the attribute is removed.

    For nodes which are text only the value of the data may be replace, and "attribute" may not be specified.

    In both cases "value" is the new value. The "id" must be in the form: [name].[node], where "name" is the name of the scan, and "node" is the node name, as in "1.3.4" ...


    tag_set

    public void tag_set(RewriteContext hr)
    Steal the "set" tag away from the SetTemplate for my id prefixs! This is an experiment. Make sure we are before the SetTemplate in the template list for this to work. The following will work with set (maybe) - name.[node].attribute.[name] + set the attribute name (tags only) - name.[node].append - name.[node].prepend - name.[node] + set, prepend, or append a value to the named node If the node doesn't exist, create it, using the same tag list as the original scan.


    Version Kenai-svn-r24, Generated 08/18/09
    Copyright (c) 2001-2009, Sun Microsystems.