apache > lenya
 

Forms Editor

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="&lt;xupdate:append select=&quot;/sidebar&quot;&gt;&lt;xupdate:element name=&quot;block&quot;&gt;&lt;title&gt;New title&lt;/title&gt;&lt;content&gt;New content&lt;/content&gt;&lt;/xupdate:element&gt;&lt;/xupdate:append&gt;"/></action>
  </node>
</xsl:template>

<xsl:template match="block">
  <node name="Add Block">
    <action><insert name="&lt;xupdate:insert-before select=&quot;/sidebar/block[@tagID='{@tagID}']&quot;&gt;&lt;xupdate:element name=&quot;block&quot;&gt;&lt;title&gt;New title&lt;/title&gt;&lt;content&gt;New content&lt;/content&gt;&lt;/xupdate:element&gt;&lt;/xupdate:insert-before&gt;"/></action>
  </node>
  <node name="Delete Block">
    <action><delete name="&lt;xupdate:remove select=&quot;/sidebar/block[@tagID='{@tagID}']&quot;/&gt;"/></action>
  </node>
  <node name="Title" select="/sidebar/block/title[@tagID='{title/@tagID}']">
    <content type="plain"><input type="text" name="&lt;xupdate:update select=&quot;/sidebar/block/title[@tagID='{title/@tagID}']&quot;&gt;" 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="&lt;xupdate:update select=&quot;/sidebar/block/content[@tagID='{content/@tagID}']&quot;&gt;" 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="&lt;xupdate:update select=&quot;/*/xhtml:table[@tagID='{@tagID}']/@class&quot;&gt;" cols="40" rows="2">
        <xsl:value-of select="@class"/>
      </textarea>
    </content>
  </node>
</xsl:template>