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 2007/11/22 01:39:57 UTC

svn commit: r597275 - in /lenya/trunk: lib/ src/cocoon/ src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/ src/modules/editors/usecases/forms/

Author: andreas
Date: Wed Nov 21 16:39:55 2007
New Revision: 597275

URL: http://svn.apache.org/viewvc?rev=597275&view=rev
Log:
Change forms editor to use xindice libraries for XUpdate. Append declared namespaces to XUpdate namespace map. Removed obsolete custom xmldb libraries. This fixes bug 43932.

Removed:
    lenya/trunk/lib/xmldb-common-2003-09-02.jar
    lenya/trunk/lib/xmldb-xupdate-20040205.jar
Modified:
    lenya/trunk/src/cocoon/local.blocks.properties
    lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/FormsEditor.java
    lenya/trunk/src/modules/editors/usecases/forms/form-layout.xsl

Modified: lenya/trunk/src/cocoon/local.blocks.properties
URL: http://svn.apache.org/viewvc/lenya/trunk/src/cocoon/local.blocks.properties?rev=597275&r1=597274&r2=597275&view=diff
==============================================================================
--- lenya/trunk/src/cocoon/local.blocks.properties (original)
+++ lenya/trunk/src/cocoon/local.blocks.properties Wed Nov 21 16:39:55 2007
@@ -108,7 +108,7 @@
 include.block.web3=false
 #-----[dependency]: "xmldb" depends on "databases".
 # TODO: Including the xmldb block might cause a conflict with the patched xmldb libraries lib/xmldb-common-2003-09-02.jar and lib/xmldb-xupdate-2003-10-14.jar
-include.block.xmldb=false
+#include.block.xmldb=false
 #-----[dependency]: "xsp" is needed by "databases", "itext", "linkrewriter", "python", "session-fw", "woody".
 #include.block.xsp=false
 

Modified: lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/FormsEditor.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/FormsEditor.java?rev=597275&r1=597274&r2=597275&view=diff
==============================================================================
--- lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/FormsEditor.java (original)
+++ lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/forms/FormsEditor.java Wed Nov 21 16:39:55 2007
@@ -58,6 +58,9 @@
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.ValidationUtil;
 import org.apache.lenya.xml.XPath;
+import org.apache.xindice.core.xupdate.XPathQueryFactoryImpl;
+import org.apache.xindice.core.xupdate.XUpdateImpl;
+import org.apache.xindice.xml.NamespaceMap;
 import org.apache.xml.utils.PrefixResolver;
 import org.apache.xml.utils.PrefixResolverDefault;
 import org.apache.xpath.XPathAPI;
@@ -67,11 +70,7 @@
 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.
@@ -217,10 +216,7 @@
      * @throws TransformerException
      */
     private void save(SourceResolver resolver, org.apache.lenya.cms.publication.Document lenyaDocument,
-            Source unnumberTagsXslSource, Source numberTagsXslSource,String encoding) throws ProcessingException,
-            FactoryConfigurationError, ParserConfigurationException, IOException, SAXException,
-            XPathQueryConfigurationException, Exception, MalformedURLException,
-            TransformerConfigurationException, TransformerException {
+            Source unnumberTagsXslSource, Source numberTagsXslSource,String encoding) throws Exception {
         if (!lenyaDocument.exists()) {
             throw new ProcessingException("The document [" + lenyaDocument + "] does not exist.");
         }
@@ -242,9 +238,9 @@
         
         System.setProperty(XPathQueryFactory.class.getName(), XPathQueryFactoryImpl.class.getName());
 
-        XUpdateQuery xUpdateQuery = new XUpdateQueryImpl();
+        XUpdateImpl xUpdate = new XUpdateImpl();
 
-        String editSelect = processElements(renumberedDocument, xUpdateQuery);
+        String editSelect = processElements(renumberedDocument, xUpdate);
         setParameter("editSelect", editSelect);
 
         Source validationSource = null;
@@ -296,7 +292,7 @@
      * @return A string.
      * @throws Exception
      */
-    private String processElements(Document document, XUpdateQuery xq) throws Exception {
+    private String processElements(Document document, XUpdateImpl xq) throws Exception {
         String editSelect = null;
         String[] paramNames = getParameterNames();
         for (int paramIndex = 0; paramIndex < paramNames.length; paramIndex++) {
@@ -386,14 +382,14 @@
                     // NOTE: select/option is generating parameter
                     // which should be considered as null
                     if (xupdateModifications != null) {
-                        xupdateModifications = "<?xml version=\"1.0\"?>"
-                                + addHiddenNamespaces(namespaces, xupdateModifications);
+                        xupdateModifications = "<?xml version=\"1.0\"?>" + xupdateModifications;
                     }
 
                     // now run the assembled xupdate query
                     if (xupdateModifications != null) {
                         getLogger().info("Execute XUpdate Modifications: " + xupdateModifications);
                         xq.setQString(xupdateModifications);
+                        xq.setNamespaceMap(getNamespaceMap(namespaces));
                         xq.execute(document);
                     } else {
                         getLogger().debug("Parameter did not match any xupdate command: " + pname);
@@ -403,6 +399,27 @@
             }
         }
         return editSelect;
+    }
+
+    protected NamespaceMap getNamespaceMap(String namespaces) {
+        NamespaceMap nsMap = new NamespaceMap();
+        String[] namespace = namespaces.split("[\\s]+");
+        for (int i = 0; i < namespace.length; i++) {
+            String[] prefixAndUri = namespace[i].split("=");
+            String prefix = prefixAndUri[0];
+            String uri = prefixAndUri[1].replaceAll("\"", "");
+            
+            int colonIndex = prefix.indexOf(":");
+            if (colonIndex == -1) {
+                nsMap.setDefaultNamespace(uri);
+            } else {
+                prefix = prefix.substring(colonIndex + 1);
+                if (!nsMap.containsKey(prefix)) {
+                    nsMap.setNamespace(prefix, uri);
+                }
+            }
+        }
+        return nsMap;
     }
 
     /**

Modified: lenya/trunk/src/modules/editors/usecases/forms/form-layout.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/usecases/forms/form-layout.xsl?rev=597275&r1=597274&r2=597275&view=diff
==============================================================================
--- lenya/trunk/src/modules/editors/usecases/forms/form-layout.xsl (original)
+++ lenya/trunk/src/modules/editors/usecases/forms/form-layout.xsl Wed Nov 21 16:39:55 2007
@@ -37,7 +37,16 @@
 <div>
 <div class="lenya-box">
   <div class="lenya-box-title" style="text-align: right">
-    <input type="hidden" name="namespaces"><xsl:attribute name="value"><xsl:apply-templates select="//*" mode="namespaces" /></xsl:attribute></input>
+    <input type="hidden" name="namespaces">
+      <xsl:attribute name="value">
+        <xsl:for-each select="//namespace">
+          <xsl:text>xmlns:</xsl:text>
+          <xsl:value-of select="@prefix"/>="<xsl:value-of select="@uri"/>"
+          <xsl:text> </xsl:text>
+        </xsl:for-each>
+        <xsl:apply-templates select="//*" mode="namespaces" />
+      </xsl:attribute>
+    </input>
     <input type="submit" value="SAVE" name="submit"/>&#160;<input type="submit" value="CANCEL" name="cancel"/>
   </div>
   <div class="lenya-box-body">



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org