Forms Editor
Table of Contents
XUpdate
The Forms Editor is using the XUpdate specification from the xmldb group to update elements and attributes. You can test-drive the XUpdate engine in Lenya by doing the following:
java -classpath lib/xmldb-common-2003-09-02.jar:lib/xmldb-xupdate-2003-09-02.jar:lib/log4j-1.2.8.jar:build/lenya/webapp/WEB-INF/lib/xercesImpl-2.4.0.jar:build/lenya/webapp/WEB-INF/lib/xalan-2.5.1.jar org.xmldb.xupdate.lexus.XUpdateQueryImpl xupdate.xml entry.xml
Customization
Customization of the Forms Editor is done with stylesheets. You need to have one stylesheet for each doctype. The
stylesheet goes into lenya/xslt/formeditor/mydoctype.xsl
. A simple stylesheet may look like
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="../../../../../xslt/authoring/edit/form.xsl"/> <xsl:template match="sidebar"> <xsl:apply-templates select="block"/> <node name="Add Block"> <action><insert name="<xupdate:append select="/sidebar"><xupdate:element name="block"><title>New title</title><content>New content</content></xupdate:element></xupdate:append>"/></action> </node> </xsl:template> <xsl:template match="block"> <node name="Add Block"> <action><insert name="<xupdate:insert-before select="/sidebar/block[@tagID='{@tagID}']"><xupdate:element name="block"><title>New title</title><content>New content</content></xupdate:element></xupdate:insert-before>"/></action> </node> <node name="Delete Block"> <action><delete name="<xupdate:remove select="/sidebar/block[@tagID='{@tagID}']"/>"/></action> </node> <node name="Title" select="/sidebar/block/title[@tagID='{title/@tagID}']"> <content type="plain"><input type="text" name="<xupdate:update select="/sidebar/block/title[@tagID='{title/@tagID}']">" size="40"><xsl:attribute name="value"><xsl:value-of select="title"/></xsl:attribute></input></content> </node> <node name="Content" select="/sidebar/block/content[@tagID='{content/@tagID}']"> <content type="mixed"> <textarea name="<xupdate:update select="/sidebar/block/content[@tagID='{content/@tagID}']">" cols="40" rows="3"> <xsl:copy-of select="content/node()"/> </textarea> </content> </node> </xsl:template> </xsl:stylesheet>
Editing attributes
To add editing of attributes, you need to change the XPath and XUpdate statements to select the attribute:
<xsl:template match="xhtml:table"> <node name="Background Color" select="/*/xhtml:table[@tagID='{@tagID}']/@class"> <content> <textarea name="<xupdate:update select="/*/xhtml:table[@tagID='{@tagID}']/@class">" cols="40" rows="2"> <xsl:value-of select="@class"/> </textarea> </content> </node> </xsl:template>