commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Libbrecht <p...@activemath.org>
Subject Re: [jelly]Using Jelly to output HTML content
Date Tue, 07 Jan 2003 22:07:33 GMT

On Mardi, janv 7, 2003, at 20:16 Europe/Brussels, Kelly Chen wrote:
> I ran into several XML parsing error in this test.
> 1. OK in HTML: <img src="./dot.gif" height="5" width="20">
> Error in XML, because <img> is not closed. There are several other 
> tags that 2. The second class of problems: some usage of HTML keyword 
> break XML parsing completely. For example:
> <td nowrap ...>

For this the practice is to use XHTML in your jelly source (or whatever 
XML) then use an XML outputter "for html". This is the way most 
stylesheet processor work: you have an html output-format in xsltproc, 
xalan, saxon...

> <?xml version="1.0" encoding="utf8"?>
> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" 
> xmlns:html="jelly:html">
> .... HTML content
> </j:jelly>

I am not sure there is an HTML output method for Jelly, it would not be 
hard to write, presumably using a Xerces or Xalan for just that must be 
doable (doesn't NeckoHTML include this? it should be a tag as well!).

However, putting some HTML content in this jelly source is not going to 
work (it will not be parseable, the real bone in the parseable is the 
no requirement to close tags, like <p> tags, not so much what you 
quoted).

There are however some HTML supporting tags which allow you to parse 
HTML and apply all sorts of Jelly tricks, the tag library documentation 
says:


Tag Documentation

[tag libraries] [tags]

The following document contains a summary of all the coreJellytag 
libraries.
Tag Libraries

[tag libraries] [tags]
Library Description
jelly:core

The core Tags from the JSTL
jelly:xml

The XML Tags from the JSTL
jelly:define

Tag library which allows the creation of new tags using Jelly script 
itself.
jelly:sql

The SQL Tags from the JSTL

There are some examples of these tags in action here
jelly:jsl

The Jelly Stylesheet Library (JSL)

The JSL tag library implements an XSLT-like declarative XML based 
processing engine which allows dynamic stylesheets and a free mix and 
match of all Jelly tags within the script.

The JSL tag library relies on the XML tags in JSTL to do most of its 
work, so JSL just provides the declarative XML processing via < 
jsl:stylesheet > < jsl:template > and < jsl:applyTemplates >
jelly:ant

A tag library for using Ant tasks within Jelly

Jelly can be invoked inside Ant and this tag library allows Ant tasks 
to be invoked from inside Jelly. This allows Jelly to be used for more 
'scripting' style targets, such as parsing XML databases, working with 
custom java beans, doing SQL, the use of JSTL and so forth.
jelly:beanshell

A tag library for working with BeanShell expressions and scripts within 
Jelly
jelly:werkz

A tag library for defining targets (goals) and having pre/post 
dependencies which uses the Werkz library for resolving goals and 
dependencies.
jelly:jeez

This tag library groups together the ant and werkz tag libraries into 
one namespace. This allows Maven scripts to set this as the default 
namespace to avoid folks having to use namespace prefixes for common 
stuff.
jelly:log

Custom tags for generating textual logging information using 
commons-logging which will use either log4j, logkit or JDK1.4 logging 
depending on the classpath and configuration.
jelly:ojb

A variety of tags for working with the ObjectBridge persistence engine
jelly:jms

A tag library for working with JMS using the Messenger project
jelly:validate

A tag library for validating XML using various schema languages like 
DTD, XML Schema, Relax NG as well as Relax and TREX. This tag library 
uses the JARV API to perform the validation. By default we use the MSV 
library by Kohsuke Kawaguchi as the implementation of JARV.
jelly:http

A tag library for working with HTTP, performing HTTP GET, POST and 
other actions
jelly:interaction

A simple interaction tag library so that Jelly scripts can be 
interactive.
jelly:antlr

A tag library for working with the Antlr library
jelly:util

A number of utility tags such as for tokenizing Strings.
jelly:html

Tags for parsing HTML so that it can be processed by Jelly using Andy 
Clark's NeckoHTML
jelly:junit

A collection of JUnit tags for performing unit tests written in Jelly 
script.

The < suite > tag allows a test suite to be created and then test cases 
can either be individually ran or the whole suite ran.

The < case > tag allows a single test case to be created as part of a 
suite.

The < run > tag can be used to run a given Test, TestCase or TestSuite

There is an example of these tags in action here
jelly:swing

The JellySwing Library which is a Jelly Library for creating Rich User 
Interfaces using Swing via XML markup (a Jelly script)
jelly:quartz

A tag library for scheduling tasks to be run using the Quartz library
jelly:betwixt

A tag library for turning XML into beans or beans into XML using the 
Betwixt library
jelly:dynabean

A tag library for creating new DynaClass and DynaBean objects from the 
beanutils library
jelly:email

Tags for sending email using the JavaMail API
jelly:core

The core Tags from the JSTL
Tag Name Description
remove A tag which removes the variable of the given name from the 
current variable scope.
useBean A tag which instantiates an instance of the given class and 
then sets the properties on the bean. The class can be specified via a 
{@link java.lang.Class} instance or a String which will be used to load 
the class using either the current thread's context class loader or the 
class loader used to load this Jelly library. This tag can be used it 
as follows,

       < j:useBean var="person" class="com.acme.Person" name="James" 
location="${loc}"/ > < j:useBean var="order" class="${orderClass}" 
amount="12" price="123.456"/ >


useList A tag which creates a List implementation and optionally adds 
all of the elements identified by the items attribute. The exact 
implementation of List can be specified via the class attribute
expr A tag which evaluates an expression out
when A tag which conditionally evaluates its body based on some 
condition
catch A tag which catches exceptions thrown by its body. This allows 
conditional logic to be performed based on if exceptions are thrown or 
to do some kind of custom exception logging logic.
otherwise The otherwise block of a choose/when/otherwise group of tags
thread A tag that spwans the contained script in a separate thread
forEach A tag which performs an iteration over the results of an XPath 
expression
set A tag which sets a variable from the result of an expression
whitespace A simple tag used to preserve whitespace inside its body
jelly The root Jelly tag which should be evaluated first
setProperties A tag which sets the bean properties on the given bean. 
So if you used it as follows, for example using the < j:new > tag.

       < j:new className="com.acme.Person" var="person"/ > < 
j:setProperties object="${person}" name="James" location="${loc}"/ >


Then it would set the name and location properties on the bean denoted 
by the expression ${person}.
file A tag that pipes its body to a file denoted by the name attribute 
or to an in memory String which is then output to a variable denoted by 
the var variable.
include A tag which conditionally evaluates its body based on some 
condition
while A tag which performs an iteration while the result of an 
expression is true.
choose A tag which conditionally evaluates its body based on some 
condition
scope A tag which creates a new child variable scope for its body. So 
any variables defined within its body will no longer be in scope after 
this tag.
if A tag which conditionally evaluates its body based on some condition
new A tag which creates a new object of the given type
import Imports another script.

By default, the imported script does not have access to the parent 
script's variable context. This behaviour may be modified using the 
inherit attribute.
jelly:xml

The XML Tags from the JSTL
Tag Name Description
parse A tag which parses some XML and defines a variable with the 
parsed Document. The XML can either be specified as its body or can be 
passed in via the xml property which can be a Reader, InputStream, URL 
or String URI.
transform A tag which parses some XML, applies an xslt transform to it 
and defines a variable with the transformed Document. The XML can 
either be specified as its body or can be passed in via the xml 
property which can be a Reader, InputStream, URL or String URI. The XSL 
can be passed in via the xslt property which can be a Reader, 
InputStream, URL or String URI.
copy A tag which performs a copy operation like the XSLT tag, 
performing a shallow copy of the element and its attributes but no 
content.
if Evaluates the XPath expression to be a boolean and only evaluates 
the body if the expression is true.
element A tag to produce an XML element which can contain other 
attributes or elements like the < xsl:element > tag.
forEach A tag which performs an iteration over the results of an XPath 
expression
copyOf A tag which performs a copy-of operation like the XSLT tag
attribute Adds an XML attribute to the parent element tag like the < 
xsl:attribute > tag.
expr A tag which performs a string XPath expression; similar to < 
xsl:value-of > in XSLT
param Sets a parameter in the parent transform tag
set A tag which defines a variable from an XPath expression
jelly:define

Tag library which allows the creation of new tags using Jelly script 
itself.
Tag Name Description
dynaBean Binds a Java bean to the given named Jelly tag so that the 
attributes of the tag set the bean properties..
bean Binds a Java bean to the given named Jelly tag so that the 
attributes of the tag set the bean properties..
script < script > tag is used to assign a Script object to a variable. 
The script can then be called whenever the user wishes maybe from 
inside an expression or more typically via the < invoke > tag.
invoke The < invoke > tag will invoke a given Script instance. It can 
be used with the < script > tag which defines scripts as variables that 
can later be invoked by this < invoke > tag.
tag < tag > is used to define a new tag using a Jelly script to 
implement the behaviour of the tag. Parameters can be passed into the 
new tag using normal XML attribute notations. Inside the body of the 
tag definition, the attributes can be accessed as normal Jelly 
variables.
invokeBody < invokeBody > tag is used inside a < tag > tag (i.e. the 
definition of a dynamic tag) to invoke the tags body when the tag is 
invoked.
taglib The < taglib > tag is used to define a new tag library using a 
Jelly script..
classLoader Creates a new URLClassLoader to dynamically load tags froms.
attribute This tag is bound onto a Java Bean class. When the tag is 
invoked a bean will be created using the tags attributes. The bean may 
also have an invoke method called invoke(), run(), execute() or some 
such method which will be invoked after the bean has been configured.
jellyBean Binds a Java bean to the given named Jelly tag so that the 
attributes of the tag set the bean properties. After the body of this 
tag is invoked then the beans invoke() method will be called, if the 
bean has one.
jelly:sql

The SQL Tags from the JSTL

There are some examples of these tags in action here
Tag Name Description
transaction

Tag handler for < Transaction > in JSTL.
driver

Tag handler for < Driver > in JSTL, used to create a simple DataSource 
for prototyping.
query

Tag handler for < Query > in JSTL.
dateParam

Tag handler for < Param > in JSTL, used to set parameter values for a 
SQL statement.
update

Tag handler for < Update > in JSTL.
resultSet This Tag creates a result set object based on its body 
content via child row tags. This tag is useful for unit testing with 
Mock Tags to simulate the results returned by databases.
param

Tag handler for < Param > in JSTL, used to set parameter values for a 
SQL statement.
row Adds a new row to a parent < resultSet > Tag. This tag is useful 
for unit testing with Mock Tags to simulate the results returned by 
databases.
setDataSource

Tag handler for < SetDataSource > in JSTL, used to create a simple 
DataSource for prototyping.
jelly:jsl

The Jelly Stylesheet Library (JSL)

The JSL tag library implements an XSLT-like declarative XML based 
processing engine which allows dynamic stylesheets and a free mix and 
match of all Jelly tags within the script.

The JSL tag library relies on the XML tags in JSTL to do most of its 
work, so JSL just provides the declarative XML processing via < 
jsl:stylesheet > < jsl:template > and < jsl:applyTemplates >
Tag Name Description
style This tag performs a JSL stylesheet which was previously created 
via an < stylesheet > tag.
template This tag represents a declarative matching rule, similar to 
the template tag in XSLT.
stylesheet This tag implements a JSL stylesheet which is similar to an 
XSLT stylesheet but can use Jelly tags inside it
applyTemplates Implements the apply templates function in the 
stylesheet, similar to the XSLT equivalent. a JSP include.
jelly:ant

A tag library for using Ant tasks within Jelly

Jelly can be invoked inside Ant and this tag library allows Ant tasks 
to be invoked from inside Jelly. This allows Jelly to be used for more 
'scripting' style targets, such as parsing XML databases, working with 
custom java beans, doing SQL, the use of JSTL and so forth.
Tag Name Description
setProperty Tag which sets an attribute on the parent Ant Task if the 
given value is not null. This can be useful when setting parameters on 
Ant tasks, only if they have been specified via some well defined 
property, otherwise allowing the inbuilt default to be used.
ant Tag supporting ant's Tasks as well as dynamic runtime behaviour for 
'unknown' tags.
fileScanner A tag which creates a new FileScanner bean instance that 
can be used to iterate over fileSets
jelly:beanshell

A tag library for working with BeanShell expressions and scripts within 
Jelly
Tag Name Description
script A tag which invokes a BeanShell script..
jelly:werkz

A tag library for defining targets (goals) and having pre/post 
dependencies which uses the Werkz library for resolving goals and 
dependencies.
Tag Name Description
attainGoal Attains one or more goals.
goal Implements a < target > tag which is similar to the Ant equivalent 
tag but is based on the Werkz goal engine.
attain Attains one or more goals.
postGoal Implements a < postGoal > tag which provides a callback which 
is evaluated after a goal has executed.
preGoal Implements a < preGoal > tag which provides a callback which is 
evaluated before a goal.
project The root tag of a Project definition.
postAction Implements a < postAction > tag which provides a callback 
which is evaluated after an action.
preAction Implements a < preAction > tag which provides a callback 
which is evaluated before an action.
jelly:jeez

This tag library groups together the ant and werkz tag libraries into 
one namespace. This allows Maven scripts to set this as the default 
namespace to avoid folks having to use namespace prefixes for common 
stuff.
Tag Name Description
target Wraps a Werkz < goal > to appear as an ant < target > .
tagDef This tag defines a dynamic tag in Jelly script. When the tag is 
invoked any attributes will be passed in as variables and the 
definition of the tag can use < define:invokeBody &gt to invoke its 
body.

This tag is similar to the < define:tag > tag in the define tag library.
jelly:log

Custom tags for generating textual logging information using 
commons-logging which will use either log4j, logkit or JDK1.4 logging 
depending on the classpath and configuration.
Tag Name Description
fatal A tag which generates FATAL level logging statement using the 
given category name.
info A tag which generates INFO level logging statement using the given 
category name.
warn A tag which generates WARN level logging statement using the given 
category name.
trace A tag which generates TRACE level logging statement using the 
given category name.
debug A tag which generates DEBUG level logging statement using the 
given category name.
error A tag which generates ERROR level logging statement using the 
given category name.
jelly:ojb

A variety of tags for working with the ObjectBridge persistence engine
Tag Name Description
broker

Tag handler for < Driver > in JSTL, used to create a simple DataSource 
for prototyping.
store

This Store tag will store the given object in ObjectBridge using the 
given broker or it will use the parent broker tags broker instance.
jelly:jms

A tag library for working with JMS using the Messenger project
Tag Name Description
destination Creates a Destination object from a String name.
subscribe Performs a subscription to some JMS connection to a 
destination maybe with a selector. A JMS MessageListener can be 
specified, or a special child tag can explicitly set it on its parent 
(so a special tag could construct a MessageListener object and register 
it with this tag).
send Sends a JMS message to some destination.
message A tag which creates a JMS message
connection Defines a JMS connection for use by other JMS tags.
mapMessage Creates a JMS MapMessage
textMessage Creates a JMS TextMessage
property Defines a property on an outer JMS Message tag
objectMessage Creates a JMS ObjectMessage
mapEntry Adds a map entry to the outer Map Message tag
receive Receives a JMS message.
jelly:validate

A tag library for validating XML using various schema languages like 
DTD, XML Schema, Relax NG as well as Relax and TREX. This tag library 
uses the JARV API to perform the validation. By default we use the MSV 
library by Kohsuke Kawaguchi as the implementation of JARV.
Tag Name Description
verifier This tag creates a new Verifier of a schema as a variable so 
that it can be used by a < validate > tag.
validate This tag validates its body using a schema Verifier which can 
validate against DTDs, XML Schema, RelaxNG, Relax or TREX. Any JARV 
compliant Verifier could be used. The error messages are output as XML 
events so that they can be styled by the parent tag.
assertValid This tag performs an assertion that the tags body contains 
XML which matches a givem schema validation. This tag is used with 
JellyUnit to implement an assertion.
jelly:http

A tag library for working with HTTP, performing HTTP GET, POST and 
other actions
Tag Name Description
post A http post
header A tag to hold request headers
get A http get tag
delete A http delete tag
head A http get tag
session A http session. This is the container for data shared across 
requests
put A http put
options A http get tag
parameter A tag to hold parameters
body A tag to set the body for posts and puts etc
jelly:interaction

A simple interaction tag library so that Jelly scripts can be 
interactive.
Tag Name Description
ask Jelly Tag that asks the user a question, and puts his answer into a 
variable, with the attribute "answer". This variable may be reused 
further as any other Jelly variable.
jelly:antlr

A tag library for working with the Antlr library
Tag Name Description
antlr
grammar
jelly:util

A number of utility tags such as for tokenizing Strings.
Tag Name Description
sleep A tag which sleeps for a given amount of time.
loadText A tag which catches exceptions thrown by its body. This allows 
conditional logic to be performed based on if exceptions are thrown or 
to do some kind of custom exception logging logic.
tokenize
properties A tag which loads a properties file from a given file name 
or URI which are loaded into the current context.
jelly:html
Tags for parsing HTML so that it can be processed by Jelly using Andy 
Clark's NeckoHTML
"html:parse": A tag which parses some HTML and defines a variable with 
the parsed Document. The HTML can either be specified as its body or 
can be passed in via the html property which can be a Reader, 
InputStream, URL or String URI.

html= java.lang.Object Sets the source of the HTML which is either a 
String URI, Reader or InputStream
var= java.lang.String Sets the variable name that will be used for the 
Document variable created
SAXReader= org.dom4j.io.SAXReader Sets the SAXReader used for parsing
trim= boolean Sets whether whitespace inside this tag should be trimmed 
or not. Defaults to true so whitespace is trimmed

Hope that helps.

Paul


Mime
View raw message