You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/04/11 23:40:49 UTC
svn commit: r160958 - in lenya/trunk/src: java/org/apache/lenya/cms/editors/
java/org/apache/lenya/cms/editors/forms/
java/org/apache/lenya/cms/publication/usecases/ webapp/WEB-INF/
webapp/lenya/pubs/default/config/doctypes/schemas/
webapp/lenya/pubs/default/config/menus/
webapp/lenya/pubs/default/lenya/usecases/edit/
webapp/lenya/pubs/default/lenya/usecases/edit/forms/
webapp/lenya/pubs/default/lenya/xslt/formeditor/
webapp/lenya/usecases/edit/ webapp/lenya/usecases/edit/forms/
Author: andreas
Date: Mon Apr 11 14:40:46 2005
New Revision: 160958
URL: http://svn.apache.org/viewcvs?view=rev&rev=160958
Log:
migrated forms editor to usecase framework
Added:
lenya/trunk/src/java/org/apache/lenya/cms/editors/
lenya/trunk/src/java/org/apache/lenya/cms/editors/EditDocument.java
lenya/trunk/src/java/org/apache/lenya/cms/editors/forms/
lenya/trunk/src/java/org/apache/lenya/cms/editors/forms/FormsEditor.java
lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/
lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/
lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/homepage.xsl
lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml-common.xsl
lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/forms/
lenya/trunk/src/webapp/lenya/usecases/edit/forms.jx
lenya/trunk/src/webapp/lenya/usecases/edit/forms/copy-mixed-content.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/forms/form-layout.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/forms/form.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/forms/numberTags.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/forms/unnumberTags.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/usecase.xmap
Removed:
lenya/trunk/src/java/org/apache/lenya/cms/publication/usecases/EditDocument.java
Modified:
lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
lenya/trunk/src/webapp/lenya/pubs/default/config/doctypes/schemas/lenya.rng
lenya/trunk/src/webapp/lenya/pubs/default/config/menus/generic.xsp
lenya/trunk/src/webapp/lenya/pubs/default/lenya/xslt/formeditor/xhtml.xsl
lenya/trunk/src/webapp/lenya/usecases/edit/usecase-edit.xmap
Added: lenya/trunk/src/java/org/apache/lenya/cms/editors/EditDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/editors/EditDocument.java?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/editors/EditDocument.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/editors/EditDocument.java Mon Apr 11 14:40:46 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.editors;
+
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.cocoon.source.SourceUtil;
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.cms.workflow.WorkflowManager;
+import org.apache.lenya.transaction.TransactionException;
+
+/**
+ * Usecase to edit documents.
+ *
+ * @version $Id:$
+ */
+public class EditDocument extends DocumentUsecase {
+
+ /**
+ * The URI to copy the document source from.
+ */
+ public static final String SOURCE_URI = "sourceUri";
+
+ /**
+ * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
+ */
+ protected void doExecute() throws Exception {
+ super.doExecute();
+ SourceResolver resolver = null;
+ WorkflowManager wfManager = null;
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ SourceUtil.copy(resolver, getParameterAsString(SOURCE_URI), getSourceDocument()
+ .getSourceURI());
+
+ wfManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
+ if (wfManager.canInvoke(getSourceDocument(), "edit")) {
+ wfManager.invoke(getSourceDocument(), "edit");
+ }
+
+ } finally {
+ if (resolver != null) {
+ this.manager.release(resolver);
+ }
+ if (wfManager != null) {
+ this.manager.release(wfManager);
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#lockInvolvedObjects()
+ */
+ public void lockInvolvedObjects() throws UsecaseException {
+ super.lockInvolvedObjects();
+ try {
+ getSourceDocument().lock();
+ } catch (TransactionException e) {
+ throw new UsecaseException(e);
+ }
+ }
+}
\ No newline at end of file
Added: lenya/trunk/src/java/org/apache/lenya/cms/editors/forms/FormsEditor.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/editors/forms/FormsEditor.java?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/editors/forms/FormsEditor.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/editors/forms/FormsEditor.java Mon Apr 11 14:40:46 2005
@@ -0,0 +1,741 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.editors.forms;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.MalformedURLException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.excalibur.source.ModifiableSource;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.transaction.TransactionException;
+import org.apache.lenya.xml.DocumentHelper;
+import org.apache.lenya.xml.RelaxNG;
+import org.apache.lenya.xml.XPath;
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.PrefixResolverDefault;
+import org.apache.xpath.XPathAPI;
+import org.apache.xpath.objects.XObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xmldb.common.xml.queries.XPathQueryConfigurationException;
+import org.xmldb.common.xml.queries.XPathQueryFactory;
+import org.xmldb.common.xml.queries.XUpdateQuery;
+import org.xmldb.common.xml.queries.xalan2.XPathQueryFactoryImpl;
+import org.xmldb.xupdate.lexus.XUpdateQueryImpl;
+
+/**
+ * Multiple forms editor usecase.
+ *
+ * @version $Id:$
+ */
+public class FormsEditor extends DocumentUsecase {
+
+ private static final class XUpdateAttributes {
+ /**
+ * <code>xupdateAttrExpr</code> The Xupdate expression
+ */
+ public String xupdateAttrExpr = "";
+ /**
+ * <code>tagID</code> The tag ID
+ */
+ public String tagID = "";
+
+ /**
+ * Set Xupdate attributes
+ * @param _xupdateAttrExpr The xupdate expression
+ * @param _tagID The tag id
+ */
+ public XUpdateAttributes(String _xupdateAttrExpr, String _tagID) {
+ this.xupdateAttrExpr = _xupdateAttrExpr;
+ this.tagID = _tagID;
+ }
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#lockInvolvedObjects()
+ */
+ public void lockInvolvedObjects() throws UsecaseException {
+ super.lockInvolvedObjects();
+ try {
+ getSourceDocument().lock();
+ } catch (TransactionException e) {
+ throw new UsecaseException(e);
+ }
+ }
+
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#advance()
+ */
+ public void advance() throws UsecaseException {
+ super.advance();
+
+ String form = getParameterAsString("form");
+ String pubUrl = "context://lenya/pubs/" + getSourceDocument().getPublication().getId();
+ String schemaUri = pubUrl + "/config/doctypes/schemas/" + form + ".rng";
+ String unnumberTagsXslUri = "context://lenya/usecases/edit/forms/unnumberTags.xsl";
+ String numberTagsXslUri = "context://lenya/usecases/edit/forms/numberTags.xsl";
+
+ ModifiableSource xmlSource = null;
+ Source schemaSource = null;
+ Source unnumberTagsXslSource = null;
+ Source numberTagsXslSource = null;
+
+ SourceResolver resolver = null;
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+
+ xmlSource = (ModifiableSource) resolver.resolveURI(getSourceDocument().getSourceURI());
+ schemaSource = resolver.resolveURI(schemaUri);
+ unnumberTagsXslSource = resolver.resolveURI(unnumberTagsXslUri);
+ numberTagsXslSource = resolver.resolveURI(numberTagsXslUri);
+
+ if (getParameterAsString("cancel") != null) {
+ getLogger().warn("Editing has been canceled");
+ // modifiableXmlSource.delete();
+ return;
+ }
+
+ try {
+ save(resolver, xmlSource, schemaSource, unnumberTagsXslSource, numberTagsXslSource);
+ } finally {
+
+ }
+ } catch (final Exception e) {
+ throw new UsecaseException(e);
+ } finally {
+ if (resolver != null) {
+ if (xmlSource != null) {
+ resolver.release(xmlSource);
+ }
+ if (schemaSource != null) {
+ resolver.release(schemaSource);
+ }
+ if (unnumberTagsXslSource != null) {
+ resolver.release(unnumberTagsXslSource);
+ }
+ if (numberTagsXslSource != null) {
+ resolver.release(numberTagsXslSource);
+ }
+ this.manager.release(resolver);
+ }
+ }
+ }
+
+ /**
+ * Save the Form
+ * @param resolver
+ * @param xmlSource
+ * @param schemaSource
+ * @param unnumberTagsXslSource
+ * @param numberTagsXslSource
+ * @throws ProcessingException
+ * @throws FactoryConfigurationError
+ * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws XPathQueryConfigurationException
+ * @throws Exception
+ * @throws MalformedURLException
+ * @throws TransformerConfigurationException
+ * @throws TransformerException
+ */
+ private void save(SourceResolver resolver, ModifiableSource xmlSource, Source schemaSource,
+ Source unnumberTagsXslSource, Source numberTagsXslSource) throws ProcessingException,
+ FactoryConfigurationError, ParserConfigurationException, IOException, SAXException,
+ XPathQueryConfigurationException, Exception, MalformedURLException,
+ TransformerConfigurationException, TransformerException {
+ if (!xmlSource.exists()) {
+ throw new ProcessingException("The source [" + xmlSource.getURI() + "] does not exist.");
+ }
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Save modifications to [" + xmlSource.getURI() + "]");
+ }
+
+ DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
+ parserFactory.setValidating(false);
+ parserFactory.setNamespaceAware(true);
+ parserFactory.setIgnoringElementContentWhitespace(true);
+ DocumentBuilder builder = parserFactory.newDocumentBuilder();
+
+ InputSource xmlInputSource = SourceUtil.getInputSource(xmlSource);
+ Document document = builder.parse(xmlInputSource);
+ System
+ .setProperty(XPathQueryFactory.class.getName(), XPathQueryFactoryImpl.class
+ .getName());
+
+ XUpdateQuery xUpdateQuery = new XUpdateQueryImpl();
+
+ String editSelect = processElements(document, xUpdateQuery);
+ setParameter("editSelect", editSelect);
+
+ // validate against relax ng after the updates
+ if (!schemaSource.exists()) {
+ throw new ProcessingException("Schema [" + schemaSource.getURI() + "] does not exist.");
+ }
+
+ Source validationSource = null;
+ Source unnumberTagsSource = null;
+
+ try {
+ String validationUri = xmlSource.getURI() + ".validate";
+ validationSource = resolver.resolveURI(validationUri);
+ checkModifiability(validationSource);
+
+ String unnumberTagsUri = xmlSource.getURI() + ".validate.unnumber";
+ unnumberTagsSource = resolver.resolveURI(unnumberTagsUri);
+ checkModifiability(unnumberTagsSource);
+
+ String message = validateDocument(document, schemaSource, unnumberTagsXslSource);
+
+ if (message != null) {
+ throw new UsecaseException("RELAX NG Validation failed: " + message);
+ }
+ } finally {
+ if (validationSource != null) {
+ resolver.release(validationSource);
+ }
+ if (unnumberTagsSource != null) {
+ resolver.release(unnumberTagsSource);
+ }
+ }
+
+ Document renumberedDocument = renumberDocument(document,
+ unnumberTagsXslSource,
+ numberTagsXslSource);
+ writeDocument(renumberedDocument, xmlSource);
+ }
+
+ /**
+ * Process elements
+ * @param document
+ * @param xq
+ * @return
+ * @throws Exception
+ */
+ private String processElements(Document document, XUpdateQuery xq) throws Exception {
+ String editSelect = null;
+ String[] paramNames = getParameterNames();
+ for (int paramIndex = 0; paramIndex < paramNames.length; paramIndex++) {
+ String pname = paramNames[paramIndex];
+ getLogger().debug("Parameter: " + pname + " = " + getParameterAsString(pname));
+ System.out.println("Parameter: " + pname + " = " + getParameterAsString(pname));
+
+ // Extract the xpath to edit
+ if (pname.indexOf("edit[") >= 0) {
+ if (pname.endsWith("].x")) {
+ editSelect = pname.substring(5, pname.length() - 3);
+ getLogger().debug("Edit: " + editSelect);
+ System.out.println("Edit: " + editSelect);
+ }
+ deleteParameter(pname);
+ }
+
+ // Make sure we are dealing with an xupdate statement,
+ // else skip
+ if (pname.startsWith("<xupdate:")) {
+ String select = pname.substring(pname.indexOf("select") + 8);
+ select = select.substring(0, select.indexOf("\""));
+ getLogger().debug("Select Node: " + select);
+ System.out.println("Select Node: " + select);
+
+ // Check if node exists
+ PrefixResolver resolver = new FormPrefixResolver(document.getDocumentElement());
+ XObject xObject = XPathAPI.eval(document.getDocumentElement(), select, resolver);
+ NodeList nodes = xObject.nodelist();
+ if (nodes.getLength() == 0) {
+ getLogger()
+ .debug(".act(): Node does not exist (might have been deleted during update): "
+ + select);
+ } else {
+ String xupdateModifications = null;
+ // now check for the different xupdate
+ // statements, and handle appropriately
+ if (pname.indexOf("xupdate:update-parent") > 0) {
+ getLogger().debug("UPDATE PARENT Node: " + pname);
+ // CDATA updates need to be handled
+ // seperately
+ if (pname.indexOf("<![CDATA[") > 0) {
+ xupdateModifications = updateCDATA(pname, true);
+ } else {
+ xupdateModifications = update(pname, select, nodes.item(0), true);
+ }
+ } else if (pname.indexOf("xupdate:update") > 0) {
+ getLogger().debug("UPDATE Node: " + pname);
+ // CDATA updates need to be handled
+ // seperately
+ if (pname.indexOf("<![CDATA[") > 0) {
+ xupdateModifications = updateCDATA(pname, false);
+ } else {
+ xupdateModifications = update(pname, select, nodes.item(0), false);
+ }
+ } else if (pname.indexOf("xupdate:append") > 0 && pname.endsWith(">.x")) {
+ xupdateModifications = append(pname.substring(0, pname.length() - 2));
+ // insert-before: in case of select/option
+ } else if (pname.indexOf("xupdate:insert-before") > 0 && pname.endsWith("/>")) {
+ if (!getParameterAsString(pname).equals("null")) {
+ xupdateModifications = insertBefore(getParameterAsString(pname));
+ }
+ // insert-before: in case of image
+ } else if (pname.indexOf("xupdate:insert-before") > 0 && pname.endsWith(">.x")) {
+ xupdateModifications = insertBefore(pname.substring(0, pname.length() - 2));
+ // insert-after: in case of select/option
+ } else if (pname.indexOf("xupdate:insert-after") > 0 && pname.endsWith("/>")) {
+ if (!getParameterAsString(pname).equals("null")) {
+ xupdateModifications = insertAfter(getParameterAsString(pname));
+ }
+ // insert-after: in case of image
+ } else if (pname.indexOf("xupdate:insert-after") > 0 && pname.endsWith(">.x")) {
+ xupdateModifications = insertAfter(pname.substring(0, pname.length() - 2));
+ } else if (pname.indexOf("xupdate:remove") > 0 && pname.endsWith("/>.x")) {
+ xupdateModifications = remove(pname.substring(0, pname.length() - 2));
+ } else if (pname.endsWith(">.y")) {
+ getLogger().debug("Don't handle this: " + pname);
+ } else {
+ getLogger().debug("Don't handle this either: " + pname);
+ }
+
+ // Get hidden namespaces
+ String namespaces = getParameterAsString("namespaces");
+
+ // Add XML declaration
+ // NOTE: select/option is generating parameter
+ // which should be considered as null
+ if (xupdateModifications != null) {
+ xupdateModifications = "<?xml version=\"1.0\"?>"
+ + addHiddenNamespaces(namespaces, xupdateModifications);
+ }
+
+ // now run the assembled xupdate query
+ if (xupdateModifications != null) {
+ getLogger().info("Execute XUpdate Modifications: " + xupdateModifications);
+ xq.setQString(xupdateModifications);
+ xq.execute(document);
+ } else {
+ getLogger().debug("Parameter did not match any xupdate command: " + pname);
+ }
+ }
+ deleteParameter(pname);
+ }
+ }
+ return editSelect;
+ }
+
+ /**
+ * Writes a document to a modifiable source.
+ * @param document The document.
+ * @param source The source.
+ * @throws IOException if an error occurs.
+ * @throws TransformerConfigurationException if an error occurs.
+ * @throws TransformerException if an error occurs.
+ * @throws ProcessingException if an error occurs.
+ */
+ protected void writeDocument(Document document, ModifiableSource source) throws IOException,
+ TransformerConfigurationException, TransformerException, ProcessingException {
+ OutputStream oStream = source.getOutputStream();
+ Writer writer = new OutputStreamWriter(oStream);
+ DocumentHelper.writeDocument(document, writer);
+ if (oStream != null) {
+ oStream.flush();
+ try {
+ oStream.close();
+ } catch (Throwable t) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Exception closing output stream: ", t);
+ }
+ throw new ProcessingException("Could not write document: ", t);
+ }
+ }
+ if (!source.exists()) {
+ throw new ProcessingException("Could not write source [" + source.getURI() + "]");
+ }
+ }
+
+ /**
+ * Checks if a source is modifiable.
+ * @param source The source.
+ * @throws ProcessingException if the source is not modifiable.
+ */
+ protected void checkModifiability(Source source) throws ProcessingException {
+ if (!(source instanceof ModifiableSource)) {
+ throw new ProcessingException("Cannot write to source [" + source.getURI() + "]");
+ }
+ }
+
+ /**
+ * Get attributes from original node
+ * @param node Original node
+ * @return An XupdateAttributes class holding the attributes
+ */
+ private XUpdateAttributes getAttributes(Node node) {
+
+ StringBuffer buf = new StringBuffer();
+ String xupdateString = "";
+ String tagID = "";
+ org.w3c.dom.NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ for (int i = 0; i < attributes.getLength(); i++) {
+ org.w3c.dom.Attr attribute = (org.w3c.dom.Attr) attributes.item(i);
+ getLogger().debug(".getAttributes(): " + attribute.getName() + " "
+ + attribute.getValue());
+ if (!attribute.getName().equals("tagID")) {
+ String namespace = attribute.getNamespaceURI();
+ getLogger().debug(".getAttributes(): Namespace: " + namespace);
+ String namespaceAttribute = "";
+ if (namespace != null) {
+ namespaceAttribute = " namespace=\"" + namespace + "\"";
+ }
+ buf.append("<xupdate:attribute name=\"" + attribute.getName() + "\""
+ + namespaceAttribute + ">" + attribute.getValue()
+ + "</xupdate:attribute>");
+ } else {
+ buf.append("<xupdate:attribute name=\"tagID\">temp</xupdate:attribute>");
+ tagID = attribute.getValue();
+ }
+ }
+ xupdateString = buf.toString();
+ } else {
+ xupdateString = "";
+ }
+ getLogger().debug("Attributes: " + xupdateString);
+
+ return new XUpdateAttributes(xupdateString, tagID);
+ }
+
+ /**
+ * Get attributes from actual update
+ * @param update The actual update
+ * @param tagID The tag id to get the updates for
+ * @return An XupdateAttributes class holding the attributes
+ */
+ private XUpdateAttributes getAttributes(String update, String tagID) {
+ getLogger().debug(update);
+
+ String xupdateString = "<xupdate:attribute name=\"tagID\">temp</xupdate:attribute>";
+
+ String[] attributes = update.substring(0, update.indexOf(">")).split(" ");
+ for (int i = 1; i < attributes.length; i++) {
+ // TODO: beware of white spaces
+ int index = attributes[i].indexOf("=");
+ if (index > 0) {
+ String name = attributes[i].substring(0, index);
+ String value = attributes[i].substring(index + 2, attributes[i].length() - 1);
+ if (name.indexOf("xmlns") < 0) {
+ xupdateString = xupdateString + "<xupdate:attribute name=\"" + name + "\">"
+ + value + "</xupdate:attribute>";
+ }
+ }
+ }
+
+ getLogger().debug("Attributes: " + xupdateString);
+
+ return new XUpdateAttributes(xupdateString, tagID);
+ }
+
+ /**
+ * xupdate:update
+ * @param pname Name of the parent element
+ * @param select The attribute to update
+ * @param nodeToUpdate The node to update
+ * @param parent If true then parent element is part of update and attributes need to be updated
+ * resp. added or deleted
+ * @return the Xupdate statement
+ */
+ private String update(String pname, String select, Node nodeToUpdate, boolean parent) {
+ getLogger().debug("Update node: " + select);
+
+ // deal with attribute values here..
+ if (nodeToUpdate.getNodeType() == Node.ATTRIBUTE_NODE) {
+ getLogger().debug("Update attribute: " + select);
+
+ String xupdateUpdate = pname + getParameterAsString(pname) + "</xupdate:update>";
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
+ + xupdateUpdate + "</xupdate:modifications>";
+ /*
+ * And deal with mixed content here.. NOTE: Lexus has trouble with mixed content. As
+ * Workaround we insert-after the new node, remove the original node and replace the
+ * temporary tagID by the original tagID.
+ */
+ }
+
+ getLogger().debug("Update element: " + select);
+
+ String namespace = nodeToUpdate.getNamespaceURI();
+ String namespaceAttribute = "";
+ if (namespace != null) {
+ namespaceAttribute = " namespace=\"" + namespace + "\"";
+ }
+ // NOTE: getAttributes adds the attribute tagID with value "temp",
+ // which will be replaced further down
+ XUpdateAttributes xa = getAttributes(nodeToUpdate);
+ String xupdateInsertAfter = null;
+ if (parent) {
+ xa = getAttributes(getParameterAsString(pname), xa.tagID);
+ xupdateInsertAfter = "<xupdate:insert-after select=\"" + select
+ + " \"><xupdate:element name=\"" + new XPath(select).getNameWithoutPredicates()
+ + "\"" + namespaceAttribute + ">" + xa.xupdateAttrExpr
+ + removeParent(getParameterAsString(pname))
+ + "</xupdate:element></xupdate:insert-after>";
+ } else {
+ xupdateInsertAfter = "<xupdate:insert-after select=\"" + select
+ + " \"><xupdate:element name=\"" + new XPath(select).getNameWithoutPredicates()
+ + "\"" + namespaceAttribute + ">" + xa.xupdateAttrExpr
+ + getParameterAsString(pname) + "</xupdate:element></xupdate:insert-after>";
+ }
+ getLogger().debug(".update(): Update Node (insert-after): " + xupdateInsertAfter);
+
+ String xupdateRemove = "<xupdate:remove select=\"" + select + " \"/>";
+ getLogger().debug(".update(): Update Node (remove): " + xupdateRemove);
+
+ String xupdateUpdateAttribute = "<xupdate:update select=\""
+ + new XPath(select).removePredicates(select) + "[@tagID='temp']/@tagID" + " \">"
+ + xa.tagID + "</xupdate:update>";
+ getLogger().debug(".update(): Update Node (update tagID attribute): "
+ + xupdateUpdateAttribute);
+
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
+ + xupdateInsertAfter + xupdateRemove + xupdateUpdateAttribute
+ + "</xupdate:modifications>";
+ }
+
+ /**
+ * xupdate:update CDATA
+ * @param pname The name of the parent element
+ * @param parent if true then attributes of parent will also be updated
+ * @return The Xupdate expression
+ */
+ private String updateCDATA(String pname, boolean parent) {
+ String xupdateUpdate = pname + getParameterAsString(pname) + "]]></xupdate:update>";
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">"
+ + xupdateUpdate + "</xupdate:modifications>";
+ }
+
+ /**
+ * xupdate:append
+ * @param pname The node to append to
+ * @return The Xupdate statement
+ */
+ private String append(String pname) {
+ getLogger().debug(".append() APPEND Node: " + pname);
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" + pname
+ + "</xupdate:modifications>";
+ }
+
+ /**
+ * xupdate:insert-before
+ * @param pname The node to insert before
+ * @return The Xupdate statement
+ */
+ private String insertBefore(String pname) {
+ getLogger().debug(".insertBefore() INSERT-BEFORE Node: " + pname);
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" + pname
+ + "</xupdate:modifications>";
+ }
+
+ /**
+ * xupdate:insert-after
+ * @param pname The node to insert after
+ * @return The Xupdate statement
+ */
+ private String insertAfter(String pname) {
+ getLogger().debug(".insertAfter() INSERT-AFTER Node: " + pname);
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" + pname
+ + "</xupdate:modifications>";
+ }
+
+ /**
+ * xupdate:remove
+ * @param pname The node to remove
+ * @return The Xupdate statement
+ */
+ private String remove(String pname) {
+ getLogger().debug(".remove() REMOVE Node: " + pname);
+ return "<xupdate:modifications xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" + pname
+ + "</xupdate:modifications>";
+ }
+
+ /**
+ * Validates a document.
+ * @param document The document.
+ * @param schema The schema source.
+ * @param unnumberTagsXsl The source of the unnumber XSL stylesheet.
+ * @return A string. FIXME: return codes?
+ * @throws UsecaseException if an error occurs.
+ */
+ private String validateDocument(Document document, Source schema, Source unnumberTagsXsl)
+ throws UsecaseException {
+
+ try {
+ javax.xml.transform.Source xmlSource = new DOMSource(document);
+ javax.xml.transform.Source unnumberTagsXslSource = new StreamSource(unnumberTagsXsl
+ .getInputStream());
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ StreamResult unnumberXmlResult = new StreamResult(out);
+
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(unnumberTagsXslSource);
+ transformer.transform(xmlSource, unnumberXmlResult);
+
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+ InputSource unnumberXmlInputSource = new InputSource(in);
+ InputSource schemaInputSource = SourceUtil.getInputSource(schema);
+
+ return RelaxNG.validate(schemaInputSource, unnumberXmlInputSource);
+
+ } catch (Exception e) {
+ throw new UsecaseException(e);
+ }
+ }
+
+ /**
+ * Renumber the tags within a document. Each tag gets a unique number used in Xupdate
+ * expressions.
+ * @param doc The document to renumber
+ * @param unnumberTagsXSL The XSL stylesheet to remove the tagID attribute
+ * @param numberTagsXSL The XSL stylesheet to add the tagID attribute
+ * @return The renumbered document
+ * @throws UsecaseException
+ */
+ private Document renumberDocument(Document doc, Source unnumberTagsXSL, Source numberTagsXSL)
+ throws UsecaseException {
+
+ try {
+ DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
+ parserFactory.setValidating(false);
+ parserFactory.setNamespaceAware(true);
+ parserFactory.setIgnoringElementContentWhitespace(true);
+ DocumentBuilder builder = parserFactory.newDocumentBuilder();
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+
+ // Remove tagIDs
+ Transformer ut = tf.newTransformer(new StreamSource(unnumberTagsXSL.getInputStream()));
+ Document unnumberedDocument = builder.newDocument();
+ ut.transform(new DOMSource(doc), new DOMResult(unnumberedDocument));
+
+ // Add tagIDs
+ Transformer nt = tf.newTransformer(new StreamSource(numberTagsXSL.getInputStream()));
+ Document renumberedDocument = builder.newDocument();
+ nt.transform(new DOMSource(unnumberedDocument), new DOMResult(renumberedDocument));
+
+ return renumberedDocument;
+ } catch (final Exception e) {
+ throw new UsecaseException(e);
+ }
+ }
+
+ /**
+ * Remove parent element
+ * @param xmlSnippet The XML snippet to remove the parent from
+ * @return The XML snippet with the parent removed
+ */
+ private String removeParent(String xmlSnippet) {
+ String xmlSnippetWithoutParent = xmlSnippet;
+ xmlSnippetWithoutParent = xmlSnippetWithoutParent.substring(xmlSnippetWithoutParent
+ .indexOf(">") + 1);
+ xmlSnippetWithoutParent = StringUtils.reverse(xmlSnippetWithoutParent);
+ xmlSnippetWithoutParent = xmlSnippetWithoutParent.substring(xmlSnippetWithoutParent
+ .indexOf("<") + 1);
+ xmlSnippetWithoutParent = StringUtils.reverse(xmlSnippetWithoutParent);
+ return xmlSnippetWithoutParent;
+ }
+
+ /**
+ * Add namespaces to xupdate statement
+ * @param namespaces The namespaces to add
+ * @param xupdateModifications The Xupdate statement to add namespaces to
+ * @return The Xupdate statement with the added namespaces
+ */
+ private String addHiddenNamespaces(String namespaces, String xupdateModifications) {
+ getLogger().debug("Namespaces: " + namespaces);
+
+ if (namespaces == null) {
+ getLogger().debug("No additional namespaces");
+ return xupdateModifications;
+ }
+
+ String[] namespace = namespaces.split(" ");
+ String ns = "";
+ for (int i = 0; i < namespace.length; i++) {
+ if ((ns.indexOf(namespace[i]) < 0) && (xupdateModifications.indexOf(namespace[i]) < 0)) {
+ ns = ns + " " + namespace[i];
+ } else {
+ getLogger().debug("Redundant namespace: " + namespace[i]);
+ }
+ }
+
+ int endOfFirstNode = xupdateModifications.indexOf(">");
+ return xupdateModifications.substring(0, endOfFirstNode) + " " + ns
+ + xupdateModifications.substring(endOfFirstNode);
+ }
+
+ /**
+ * Prefix resolver which uses the usecase parameters like
+ * "namespace.xhtml=http://www.w3.org/1999/xhtml" to resolve prefixes.
+ */
+ public class FormPrefixResolver extends PrefixResolverDefault {
+
+ /**
+ * Ctor.
+ * @param context The context node.
+ */
+ public FormPrefixResolver(Node context) {
+ super(context);
+ }
+
+ /**
+ * @see org.apache.xml.utils.PrefixResolver#getNamespaceForPrefix(java.lang.String,
+ * org.w3c.dom.Node)
+ */
+ public String getNamespaceForPrefix(String prefix, Node context) {
+ String uri = super.getNamespaceForPrefix(prefix, context);
+ if (uri == null) {
+ uri = FormsEditor.this.getParameterAsString("namespace." + prefix);
+ }
+ return uri;
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?view=diff&r1=160957&r2=160958
==============================================================================
--- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
+++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Mon Apr 11 14:40:46 2005
@@ -414,8 +414,14 @@
</component-instance>
<component-instance name="publication.edit" logger="lenya.publication"
- class="org.apache.lenya.cms.publication.usecases.EditDocument">
+ class="org.apache.lenya.cms.editors.EditDocument">
<parameter name="sourceUri" value="cocoon:/request2document"/>
+ </component-instance>
+ <component-instance name="edit.forms" logger="lenya.publication"
+ class="org.apache.lenya.cms.editors.forms.FormsEditor">
+ <view template="edit/forms" menu="false">
+ <parameter name="formUri" value="cocoon://core/edit/form.xml"/>
+ </view>
</component-instance>
</usecases>
Modified: lenya/trunk/src/webapp/lenya/pubs/default/config/doctypes/schemas/lenya.rng
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/config/doctypes/schemas/lenya.rng?view=diff&r1=160957&r2=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/config/doctypes/schemas/lenya.rng (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/config/doctypes/schemas/lenya.rng Mon Apr 11 14:40:46 2005
@@ -48,10 +48,11 @@
<!-- namespace dummy attributes -->
<define name="dummy.attlist">
- <attribute name="dc:dummy"><ref name="Text.datatype"/></attribute>
- <attribute name="dcterms:dummy"><ref name="Text.datatype"/></attribute>
- <attribute name="lenya:dummy"><ref name="Text.datatype"/></attribute>
- <attribute name="xhtml:dummy"><ref name="Text.datatype"/></attribute>
+ <optional><attribute name="dummy"><ref name="Text.datatype"/></attribute></optional>
+ <optional><attribute name="dc:dummy"><ref name="Text.datatype"/></attribute></optional>
+ <optional><attribute name="dcterms:dummy"><ref name="Text.datatype"/></attribute></optional>
+ <optional><attribute name="lenya:dummy"><ref name="Text.datatype"/></attribute></optional>
+ <optional><attribute name="xhtml:dummy"><ref name="Text.datatype"/></attribute></optional>
</define>
Modified: lenya/trunk/src/webapp/lenya/pubs/default/config/menus/generic.xsp
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/config/menus/generic.xsp?view=diff&r1=160957&r2=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/config/menus/generic.xsp (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/config/menus/generic.xsp Mon Apr 11 14:40:46 2005
@@ -78,7 +78,7 @@
<block info="false">
<item wf:event="edit" uc:usecase="kupu" uc:step="open" href="?"><i18n:text>With Kupu</i18n:text></item>
<item wf:event="edit" uc:usecase="bxe" uc:step="open" href="?"><i18n:text>With BXE</i18n:text></item>
- <item wf:event="edit" uc:usecase="edit" uc:step="open"><xsp:attribute name="href"><xsp:expr>"?form=" + docType</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
+ <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + docType</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
<item wf:event="edit" uc:usecase="1formedit" uc:step="open" href="?"><i18n:text>With one Form</i18n:text></item>
</block>
Added: lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/homepage.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/homepage.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/homepage.xsl (added)
+++ lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/homepage.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: xhtml.xsl 42703 2004-03-13 12:57:53Z gregor $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+>
+
+<xsl:import href="xhtml.xsl"/>
+
+</xsl:stylesheet>
Added: lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml-common.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml-common.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml-common.xsl (added)
+++ lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml-common.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: xhtml-common.xsl 153165 2005-02-10 06:01:01Z gregor $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+>
+
+<xsl:template match="xhtml:body">
+<node name="Body" />
+<xsl:apply-templates mode="body"/>
+</xsl:template>
+
+<xsl:template name="insertmenu">
+<xsl:param name="path"/>
+<xsl:variable name="ns">namespace="http://www.w3.org/1999/xhtml"</xsl:variable>
+<insert-after select="{$path}[@tagID='{@tagID}']">
+ <element name="Paragraph" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:p" {$ns}>New Paragraph</xupdate:element></xupdate:insert-after>"/>
+ <element name="Table" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:table" {$ns}><tr><td>New Table</td></tr></xupdate:element></xupdate:insert-after>"/>
+ <element name="Unordered List" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:ul" {$ns}><li>New Unordered List</li>;</xupdate:element></xupdate:insert-after>"/>
+ <element name="Ordered List" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:ol" {$ns}><li>New Ordered List</li></xupdate:element></xupdate:insert-after>"/>
+ <element name="Headline 1" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:h1" {$ns}>New Headline 1</xupdate:element></xupdate:insert-after>"/>
+ <element name="Headline 2" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:h2" {$ns}>New Headline 2</xupdate:element></xupdate:insert-after>"/>
+ <element name="Headline 3" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:h3" {$ns}>New Headline 3</xupdate:element></xupdate:insert-after>"/>
+ <element name="Headline 4" xupdate="<xupdate:insert-after select="{$path}[@tagID='{@tagID}']"><xupdate:element name="xhtml:h4" {$ns}>New Headline 4</xupdate:element></xupdate:insert-after>"/>
+</insert-after>
+</xsl:template>
+
+ <xsl:template match="xhtml:p" mode="body">
+ <xsl:choose >
+ <xsl:when test="xhtml:object">
+ <xsl:apply-templates select="xhtml:object" mode="body"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <node name="Paragraph" select="/*/xhtml:body/xhtml:p[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:p[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:p[@tagID='{@tagID}']">" cols="40" rows="30">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+ </node>
+
+ <xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:p</xsl:with-param></xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<xsl:template match="xhtml:table" mode="body">
+<node name="Table" select="/*/xhtml:body/xhtml:table[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:table[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:table[@tagID='{@tagID}']">" cols="40" rows="30">
+ <xsl:copy-of select="."/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:table</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:ul" mode="body">
+<node name="Unordered List" select="/*/xhtml:body/xhtml:ul[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:ul[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:ul[@tagID='{@tagID}']">" cols="40" rows="30">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:ul</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:ol" mode="body">
+<node name="Ordered List" select="/*/xhtml:body/xhtml:ol[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:ol[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:ol[@tagID='{@tagID}']">" cols="40" rows="30">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:ol</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:h1" mode="body">
+<node name="Headline 1" select="/*/xhtml:body/xhtml:h1[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:h1[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:h1[@tagID='{@tagID}']">" cols="40" rows="3">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:h1</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:h2" mode="body">
+<node name="Headline 2" select="/*/xhtml:body/xhtml:h2[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:h2[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:h2[@tagID='{@tagID}']">" cols="40" rows="3">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:h2</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:h3" mode="body">
+<node name="Headline 3" select="/*/xhtml:body/xhtml:h3[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:h3[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:h3[@tagID='{@tagID}']">" cols="40" rows="3">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:h3</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:h4" mode="body">
+<node name="Headline 4" select="/*/xhtml:body/xhtml:h4[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:h4[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <textarea name="<xupdate:update select="/*/xhtml:body/xhtml:h4[@tagID='{@tagID}']">" cols="40" rows="3">
+ <xsl:copy-of select="node()"/>
+ </textarea>
+ </content>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:h4</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="xhtml:hr" mode="body">
+<node name="Horizontal Rule" select="/*/xhtml:body/xhtml:hr[@tagID='{@tagID}']">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:hr[@tagID='{@tagID}']"/>"/></action>
+</node>
+
+<xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body/xhtml:hr</xsl:with-param></xsl:call-template>
+
+</xsl:template>
+
+ <xsl:template match="xhtml:object" mode="body">
+ <node name="Object">
+ <action><delete name="<xupdate:remove select="/*/xhtml:body/xhtml:p/xhtml:object[@tagID='{@tagID}']"/>"/></action>
+ <content>
+ <input type="text" name="<xupdate:update select="/*/xhtml:body/xhtml:p/xhtml:object[@tagID='{@tagID}']">" size="40">
+ <xsl:attribute name="value">
+ <xsl:value-of select="@data"/>
+ </xsl:attribute>
+ </input>
+ </content>
+ </node>
+
+ <xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body</xsl:with-param></xsl:call-template>
+
+ </xsl:template>
+
+ <xsl:template match="lenya:asset" mode="body">
+ <node name="Asset">
+ <action>
+ <delete name="<xupdate:remove select="/*/xhtml:body/lenya:asset[@tagID='{@tagID}']"/>"/>
+ </action>
+ <content>
+ <input type="text" name="<xupdate:update select="/*/xhtml:body/lenya:asset[@tagID='{@tagID}']">" size="40">
+ <xsl:attribute name="value">
+ <xsl:value-of select="@src"/>
+ </xsl:attribute>
+ </input>
+ </content>
+ </node>
+
+ <xsl:call-template name="insertmenu"><xsl:with-param name="path">/*/xhtml:body</xsl:with-param></xsl:call-template>
+
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Added: lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml.xsl (added)
+++ lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/edit/forms/xhtml.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: xhtml.xsl 42703 2004-03-13 12:57:53Z gregor $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+>
+
+<xsl:import href="../../../../../../usecases/edit/forms/form.xsl"/>
+<xsl:import href="xhtml-common.xsl"/>
+
+<xsl:template match="xhtml:html">
+
+<namespace prefix="xhtml" uri="http://www.w3.org/1999/xhtml"/>
+<namespace prefix="lenya" uri="http://apache.org/cocoon/lenya/page-envelope/1.0"/>
+<namespace prefix="dc" uri="http://purl.org/dc/elements/1.1/"/>
+
+<node name="Title" select="/xhtml:html/lenya:meta/dc:title[@tagID='{lenya:meta/dc:title/@tagID}']">
+ <content><input type="text" name="<xupdate:update select="/xhtml:html/lenya:meta/dc:title[@tagID='{lenya:meta/dc:title/@tagID}']">" size="40"><xsl:attribute name="value"><xsl:value-of select="lenya:meta/dc:title"/></xsl:attribute></input></content>
+</node>
+
+<xsl:apply-templates select="xhtml:body"/>
+
+</xsl:template>
+
+</xsl:stylesheet>
Modified: lenya/trunk/src/webapp/lenya/pubs/default/lenya/xslt/formeditor/xhtml.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/lenya/xslt/formeditor/xhtml.xsl?view=diff&r1=160957&r2=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/lenya/xslt/formeditor/xhtml.xsl (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/lenya/xslt/formeditor/xhtml.xsl Mon Apr 11 14:40:46 2005
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<!-- $Id: xhtml.xsl,v 1.5 2004/03/13 12:42:18 gregor Exp $ -->
+<!-- $Id$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -24,10 +24,15 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
-<xsl:import href="../../../../../xslt/authoring/edit/form.xsl"/>
+<xsl:import href="../../../../../usecases/edit/form.xsl"/>
<xsl:import href="xhtml-common.xsl"/>
<xsl:template match="xhtml:html">
+
+<namespace prefix="xhtml" uri="http://www.w3.org/1999/xhtml"/>
+<namespace prefix="lenya" uri="http://apache.org/cocoon/lenya/page-envelope/1.0"/>
+<namespace prefix="dc" uri="http://purl.org/dc/elements/1.1/"/>
+
<node name="Title" select="/xhtml:html/lenya:meta/dc:title[@tagID='{lenya:meta/dc:title/@tagID}']">
<content><input type="text" name="<xupdate:update select="/xhtml:html/lenya:meta/dc:title[@tagID='{lenya:meta/dc:title/@tagID}']">" size="40"><xsl:attribute name="value"><xsl:value-of select="lenya:meta/dc:title"/></xsl:attribute></input></content>
</node>
Added: lenya/trunk/src/webapp/lenya/usecases/edit/forms.jx
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/forms.jx?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/forms.jx (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/forms.jx Mon Apr 11 14:40:46 2005
@@ -0,0 +1,54 @@
+<page:page
+ xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
+ xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns:cinclude="http://apache.org/cocoon/include/1.0"
+ >
+
+ <page:title><i18n:text>Edit</i18n:text></page:title>
+ <page:body>
+
+ <div class="lenya-box">
+ <div class="lenya-box-title">Information</div>
+ <div class="lenya-box-body">
+ <table class="lenya-table-noborder">
+ <tr>
+ <td class="lenya-entry-caption">Document:</td>
+ <td><jx:out value="${usecase.getParameter('document').getId()}"/></td>
+ </tr>
+ <tr>
+ <td class="lenya-entry-caption">Form:</td>
+ <td><jx:out value="${usecase.getParameter('form')}"/></td>
+ </tr>
+ <tr>
+ <td class="lenya-entry-caption">Node:</td>
+ <td><jx:out value="${usecase.getParameter('editSelect')}"/></td>
+ </tr>
+ <tr>
+ <td class="lenya-entry-caption">Workflow Event:</td>
+ <jx:set var="event" value="${request.getParameter('lenya.event')}"/>
+ <jx:choose>
+ <jx:when test="${event.equals('') || event.equals('null')}">
+ <td>No workflow event specified</td>
+ </jx:when>
+ <jx:otherwise>
+ <td><jx:out value="${event}"/></td>
+ </jx:otherwise>
+ </jx:choose>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <jx:import uri="templates/messages.jx"/>
+
+ <form method="post" action="?lenya.usecase=edit.forms">
+ <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+ <cinclude:includexml>
+ <cinclude:src>cocoon://core/edit/form/<jx:out value="${usecase.getParameter('form')}"/>/<jx:out value="${usecase.getParameter('editSelect')}"/></cinclude:src>
+ </cinclude:includexml>
+ </form>
+
+ </page:body>
+</page:page>
\ No newline at end of file
Added: lenya/trunk/src/webapp/lenya/usecases/edit/forms/copy-mixed-content.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/forms/copy-mixed-content.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/forms/copy-mixed-content.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/forms/copy-mixed-content.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,163 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: copy-mixed-content.xsl 42908 2004-04-26 14:57:25Z michi $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+
+
+
+<!-- FIXME: works bugfree, but is kind of ugly, because each element will list all namespaces -->
+<!--
+<xsl:template match="//*" mode="mixedcontent" priority="-1">
+<xsl:variable name="prefix"><xsl:if test="contains(name(),':')">:<xsl:value-of select="substring-before(name(),':')"/></xsl:if></xsl:variable>
+
+<xsl:choose>
+<xsl:when test="node()">
+<xsl:text><</xsl:text><xsl:value-of select="name()"/>
+
+<xsl:apply-templates select="@*[local-name()!='tagID']" mode="mixedcontent"/>
+
+<xsl:for-each select="namespace::*">
+<xsl:variable name="prefix"><xsl:if test="local-name() != ''">:<xsl:value-of select="local-name()"/></xsl:if></xsl:variable>
+<xsl:if test=". != 'http://www.w3.org/XML/1998/namespace'">
+<xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="."/><xsl:text>"</xsl:text>
+</xsl:if>
+</xsl:for-each>
+
+<xsl:text>></xsl:text>
+
+<xsl:apply-templates select="node()" mode="mixedcontent"/>
+
+<xsl:text></</xsl:text><xsl:value-of select="name()"/><xsl:text>></xsl:text>
+
+</xsl:when>
+
+<xsl:otherwise>
+
+<xsl:text><</xsl:text><xsl:value-of select="name()"/>
+
+<xsl:apply-templates select="@*[local-name()!='tagID']" mode="mixedcontent"/>
+
+<xsl:for-each select="namespace::*">
+<xsl:variable name="prefix"><xsl:if test="local-name() != ''">:<xsl:value-of select="local-name()"/></xsl:if></xsl:variable>
+<xsl:if test=". != 'http://www.w3.org/XML/1998/namespace'">
+<xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="."/><xsl:text>"</xsl:text>
+</xsl:if>
+</xsl:for-each>
+
+<xsl:text>/></xsl:text></xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+<xsl:template match="@*" mode="mixedcontent"><xsl:text> </xsl:text><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:template>
+-->
+
+
+
+
+
+
+
+
+
+
+<!-- List all the namespaces -->
+<xsl:template match="//*" mode="namespaces" priority="-1">
+<xsl:variable name="prefix"><xsl:if test="contains(name(),':')">:<xsl:value-of select="substring-before(name(),':')"/></xsl:if></xsl:variable>
+
+<xsl:if test="namespace-uri()"><xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="namespace-uri()"/>"</xsl:if><xsl:apply-templates select="@*[local-name()!='tagID']" mode="namespaces"/>
+<xsl:apply-templates select="node()" mode="namespaces"/>
+</xsl:template>
+
+<xsl:template match="@*" mode="namespaces">
+<xsl:variable name="prefix"><xsl:if test="contains(name(),':')">:<xsl:value-of select="substring-before(name(),':')"/></xsl:if></xsl:variable>
+
+<xsl:if test="namespace-uri()"><xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="namespace-uri()"/>"</xsl:if></xsl:template>
+
+<xsl:template match="text()" mode="namespaces"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<!-- FIXME: namespaces occur multiple times, e.g. xlink:show="" xlink:href="" xmlns:xlink="" xmlns:xlink="" -->
+<xsl:template match="//*" mode="mixedcontent" priority="-1">
+<xsl:variable name="prefix"><xsl:if test="contains(name(),':')">:<xsl:value-of select="substring-before(name(),':')"/></xsl:if></xsl:variable>
+
+<xsl:choose>
+<xsl:when test="node()">
+<xsl:text><</xsl:text><xsl:value-of select="name()"/><!--<xsl:if test="namespace-uri()"><xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="namespace-uri()"/>"</xsl:if>--><xsl:apply-templates select="@*[local-name()!='tagID']" mode="mixedcontent"/><xsl:text>></xsl:text>
+<xsl:apply-templates select="node()" mode="mixedcontent"/>
+<xsl:text></</xsl:text><xsl:value-of select="name()"/><xsl:text>></xsl:text>
+</xsl:when>
+
+<!-- Empty element (why is this not node?) -->
+<xsl:otherwise>
+<xsl:text><</xsl:text><xsl:value-of select="name()"/><!--<xsl:if test="namespace-uri()"><xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="namespace-uri()"/>"</xsl:if>--><xsl:apply-templates select="@*[local-name()!='tagID']" mode="mixedcontent"/><xsl:text> /></xsl:text>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+<!-- Attributes -->
+<xsl:template match="@*" mode="mixedcontent">
+<xsl:variable name="prefix"><xsl:if test="contains(name(),':')">:<xsl:value-of select="substring-before(name(),':')"/></xsl:if></xsl:variable>
+
+<xsl:text> </xsl:text><xsl:value-of select="name()"/>="<xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="."/></xsl:call-template>"<!--<xsl:if test="namespace-uri()"><xsl:text> </xsl:text>xmlns<xsl:value-of select="$prefix"/>="<xsl:value-of select="namespace-uri()"/>"</xsl:if>--></xsl:template>
+
+
+
+<xsl:template match="text()" mode="mixedcontent">
+ <xsl:call-template name="search-and-replace">
+ <xsl:with-param name="string" select="."/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="search-and-replace">
+<xsl:param name="string"/>
+
+<xsl:choose>
+<xsl:when test="contains($string, '<')">
+ <xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="substring-before($string, '<')"/></xsl:call-template>&lt;<xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="substring-after($string, '<')"/></xsl:call-template>
+</xsl:when>
+<xsl:when test="contains($string, '>')">
+ <xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="substring-before($string, '>')"/></xsl:call-template>&gt;<xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="substring-after($string, '>')"/></xsl:call-template>
+</xsl:when>
+<xsl:when test="contains($string, '&')">
+ <xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="substring-before($string, '&')"/></xsl:call-template>&amp;<xsl:call-template name="search-and-replace"><xsl:with-param name="string" select="substring-after($string, '&')"/></xsl:call-template>
+</xsl:when>
+<!-- FIXME: " and ' -->
+<xsl:otherwise>
+ <xsl:value-of select="$string"/>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
Added: lenya/trunk/src/webapp/lenya/usecases/edit/forms/form-layout.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/forms/form-layout.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/forms/form-layout.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/forms/form-layout.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,206 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: form-layout.xsl 155267 2005-02-24 22:41:27Z gregor $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/1999/xhtml"
+>
+
+<xsl:param name="nodeid" select="''"/>
+
+<xsl:param name="contextPrefix" select="'/lenya'"/>
+<xsl:param name="edit" select="'No node selected yet'"/>
+<xsl:param name="wfevent" select="'null'"/>
+
+<xsl:variable name="imagesPath"><xsl:value-of select="$contextPrefix"/>/lenya/images/editor</xsl:variable>
+
+<xsl:include href="copy-mixed-content.xsl"/>
+
+<xsl:template match="form">
+<div>
+<div class="lenya-box">
+ <div class="lenya-box-title" style="text-align: right">
+ <input type="submit" value="SAVE" name="submit"/> <input type="submit" value="CANCEL" name="cancel"/>
+ </div>
+ <div class="lenya-box-body">
+
+ <table class="lenya-table">
+ <xsl:apply-templates mode="nodes"/>
+ </table>
+
+ </div>
+ <div class="lenya-box-title" style="text-align: right">
+ <input type="submit" value="SAVE" name="submit"/> <input type="submit" value="CANCEL" name="cancel"/>
+ </div>
+</div>
+
+<div class="lenya-box">
+ <div class="lenya-box-title"><a href="http://www.w3.org/TR/REC-xml#syntax">Predefined Entities</a></div>
+ <div class="lenya-box-body">
+<ul>
+<li>&lt; instead of < (left angle bracket <strong>must</strong> be escaped)</li>
+<li>&amp; instead of & (ampersand <strong>must</strong> be escaped)</li>
+<li>&gt; instead of > (right angle bracket)</li>
+<li>&apos; instead of ' (single-quote)</li>
+<li>&quot; instead of " (double-quote)</li>
+</ul>
+</div>
+</div>
+
+ <xsl:variable name="currentTagID">
+ <xsl:value-of select="substring-before(substring-after($edit, "@tagID='"), "'")"/>
+ </xsl:variable>
+ <xsl:if test="$currentTagID != ''">
+ <script type="text/javascript">
+
+ function addLoadEvent(func) {
+ var oldonload = window.onload;
+ if (typeof window.onload != 'function') {
+ window.onload = func;
+ } else {
+ window.onload = function() {
+ oldonload();
+ func();
+ }
+ }
+ }
+
+ addLoadEvent(goAnchor);
+
+ function goAnchor() {
+ document.location.hash = '<xsl:value-of select="$currentTagID"/>';
+ window.scrollBy(0, -150);
+ }
+ </script>
+ </xsl:if>
+
+</div>
+</xsl:template>
+
+<xsl:template match="namespace" mode="nodes">
+ <input type="hidden" name="namespace.{@prefix}" value="{@uri}"/>
+</xsl:template>
+
+<xsl:template match="node" mode="nodes">
+<tr>
+ <td valign="top" style="background-color: #BFBFA2"><xsl:apply-templates select="action"/><xsl:if test="not(action)"> </xsl:if><xsl:apply-templates select="@select"/></td>
+ <xsl:choose>
+ <xsl:when test="content">
+ <td valign="top" style="background-color:#DCDBBF"><xsl:apply-templates select="@name"/></td>
+ <td valign="top"><xsl:apply-templates select="content"/></td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td colspan="2" valign="top" style="background-color:#DCDBBF"><xsl:apply-templates select="@name"/></td>
+ </xsl:otherwise>
+ </xsl:choose>
+</tr>
+</xsl:template>
+
+<xsl:template match="insert-before" mode="nodes">
+ <tr>
+ <td style="background-color: #BFBFA2"><input type="submit" value="INSERT BEFORE" name="insert-before"/></td>
+ <td colspan="2" style="background-color: #DCDBBF">
+ <select name="<xupdate:insert-before select="{@select}"/>" size="1">
+ <option value="null">Choose element ...</option>
+ <xsl:for-each select="element">
+ <option value="{@xupdate}"><xsl:value-of select="@name"/></option>
+ </xsl:for-each>
+ </select>
+ </td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="insert-after" mode="nodes">
+ <tr>
+ <td style="background-color: #BFBFA2"><input type="submit" value="INSERT AFTER" name="insert-after"/></td>
+ <td colspan="2" style="background-color: #DCDBBF">
+ <select name="<xupdate:insert-after select="{@select}"/>" size="1">
+ <option value="null">Choose element ...</option>
+ <xsl:for-each select="element">
+ <option value="{@xupdate}"><xsl:value-of select="@name"/></option>
+ </xsl:for-each>
+ </select>
+ </td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="node()" mode="nodes" priority="-1">
+</xsl:template>
+
+<xsl:template match="action">
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="content">
+<xsl:choose>
+<xsl:when test="$edit = ../@select">
+ <!-- TODO: what about "input" field ... -->
+ <input type="hidden" name="namespaces"><xsl:attribute name="value"><xsl:apply-templates select="textarea" mode="namespaces" /></xsl:attribute></input>
+ <xsl:apply-templates select="textarea"/>
+ <xsl:copy-of select="input"/>
+</xsl:when>
+<xsl:otherwise>
+ <p>
+ <xsl:choose>
+ <xsl:when test="(../@name='Object')">
+ <img src="{$nodeid}/{input/@value}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="input/@value"/>
+ <xsl:copy-of select="textarea/node()"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </p>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+<xsl:template match="textarea">
+<xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="mixedcontent"/>
+</xsl:copy>
+</xsl:template>
+
+<xsl:template match="insert">
+<!--
+<input type="submit" name="{@name}" value="INSERT"/>
+-->
+<xsl:text> </xsl:text>
+<input type="image" src="{$imagesPath}/add.png" name="{@name}" value="LENYA"/>
+</xsl:template>
+
+<xsl:template match="delete">
+<xsl:text> </xsl:text>
+<input type="image" src="{$imagesPath}/delete.png" name="{@name}" value="true"/>
+</xsl:template>
+
+<xsl:template match="@select">
+<xsl:text> </xsl:text>
+<!-- FIXME: Internet Explorer does not send the value of input type equals image. Mozilla does. -->
+
+<xsl:variable name="tagID">
+ <xsl:value-of select="substring-before(substring-after(., "@tagID='"), "'")"/>
+</xsl:variable>
+<xsl:value-of select="@tagID"/>
+<a name="{$tagID}"/>
+<input type="image" src="{$imagesPath}/edit.png" name="edit[{.}]" value="{.}"/>
+</xsl:template>
+
+</xsl:stylesheet>
Added: lenya/trunk/src/webapp/lenya/usecases/edit/forms/form.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/forms/form.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/forms/form.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/forms/form.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: form.xsl 42908 2004-04-26 14:57:25Z michi $ -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
+ <xsl:param name="docid"/>
+ <xsl:param name="form"/>
+ <xsl:param name="message"/>
+
+ <xsl:template match="/">
+ <form>
+ <docid><xsl:value-of select="$docid"/></docid>
+ <ftype><xsl:value-of select="$form"/></ftype>
+ <xsl:if test="$message">
+ <message><xsl:value-of select="$message"/></message>
+ </xsl:if>
+ <xsl:apply-templates/>
+ </form>
+ </xsl:template>
+
+</xsl:stylesheet>
Added: lenya/trunk/src/webapp/lenya/usecases/edit/forms/numberTags.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/forms/numberTags.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/forms/numberTags.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/forms/numberTags.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: numberTags.xsl 155356 2005-02-25 18:25:59Z gregor $ -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output method="xml" version="1.0" indent="yes"/>
+
+<xsl:template match="/">
+ <xsl:apply-templates select="*">
+ <xsl:with-param name="parentID" select="'tag'"/>
+ </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match="*|text()|@*">
+ <xsl:param name="parentID"/>
+ <xsl:variable name="thisID" select="concat($parentID,'.', count(preceding-sibling::*))"/>
+ <xsl:copy>
+ <xsl:attribute name="tagID"><xsl:value-of select="$thisID"/></xsl:attribute>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates select="*|text()|@*">
+ <xsl:with-param name="parentID" select="$thisID"/>
+ </xsl:apply-templates>
+ </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet>
Added: lenya/trunk/src/webapp/lenya/usecases/edit/forms/unnumberTags.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/forms/unnumberTags.xsl?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/forms/unnumberTags.xsl (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/forms/unnumberTags.xsl Mon Apr 11 14:40:46 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: unnumberTags.xsl 42703 2004-03-13 12:57:53Z gregor $ -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output method="xml" version="1.0" indent="yes"/>
+
+<xsl:template match="/">
+ <xsl:apply-templates select="*"/>
+</xsl:template>
+
+<!-- FIXME: there seems to be something wrong!!! (Xalan?) if something is written in front of Copy, then it works, else it doesn't ... -->
+<xsl:template match="*|text()">
+ <xsl:copy>
+ <xsl:copy-of select="@*[name()!='tagID']"/>
+ <xsl:apply-templates select="*|text()"/>
+ </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet>
Modified: lenya/trunk/src/webapp/lenya/usecases/edit/usecase-edit.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/usecase-edit.xmap?view=diff&r1=160957&r2=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/usecase-edit.xmap (original)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/usecase-edit.xmap Mon Apr 11 14:40:46 2005
@@ -15,6 +15,10 @@
limitations under the License.
-->
+<!--
+@deprecated by usecase.xmap
+-->
+
<!-- $Id$ -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
Added: lenya/trunk/src/webapp/lenya/usecases/edit/usecase.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/edit/usecase.xmap?view=auto&rev=160958
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/edit/usecase.xmap (added)
+++ lenya/trunk/src/webapp/lenya/usecases/edit/usecase.xmap Mon Apr 11 14:40:46 2005
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id$ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+ <!-- =========================== Components ================================ -->
+ <map:components/>
+ <!-- =========================== Pipelines ================================ -->
+ <map:pipelines>
+
+ <map:component-configurations>
+ <global-variables>
+ <!-- To access core resources -->
+ <basedir>../..</basedir>
+ </global-variables>
+ </map:component-configurations>
+
+ <map:pipeline>
+ <map:match pattern="form/*/**">
+ <map:generate src="lenya://lenya/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}"/>
+ <map:select type="parameter">
+ <map:parameter name="parameter-selector-test" value="{request-param:lenya.continutation}"/>
+ <map:when test="">
+ <map:transform src="fallback://lenya/usecases/edit/forms/numberTags.xsl"/>
+ </map:when>
+ </map:select>
+ <map:transform src="fallback://lenya/usecases/edit/forms/{1}.xsl">
+ <map:parameter name="docid" value="{page-envelope:document-path}"/>
+ <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
+ <map:parameter name="form" value="{1}"/>
+ </map:transform>
+ <map:transform src="fallback://lenya/usecases/edit/forms/form-layout.xsl">
+ <map:parameter name="contextPrefix" value="{page-envelope:context-prefix}"/>
+ <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
+ <map:parameter name="wfevent" value="{request-param:lenya.event}"/>
+<!-- <map:parameter name="edit" value="{flow-attribute:usecase/parameter[@name = 'editSelect']}"/> -->
+ <map:parameter name="edit" value="{2}"/>
+ </map:transform>
+ <map:serialize type="xml"/>
+ </map:match>
+ </map:pipeline>
+
+ </map:pipelines>
+
+</map:sitemap>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org