Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 91658 invoked from network); 17 Nov 2003 15:41:01 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 17 Nov 2003 15:41:01 -0000 Received: (qmail 11832 invoked by uid 500); 17 Nov 2003 15:40:30 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 11782 invoked by uid 500); 17 Nov 2003 15:40:30 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 11743 invoked by uid 500); 17 Nov 2003 15:40:29 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 11738 invoked from network); 17 Nov 2003 15:40:29 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 17 Nov 2003 15:40:29 -0000 Received: (qmail 91218 invoked by uid 1673); 17 Nov 2003 15:40:34 -0000 Date: 17 Nov 2003 15:40:34 -0000 Message-ID: <20031117154034.91216.qmail@minotaur.apache.org> From: upayavira@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/confpatch mount-table.xmap X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N upayavira 2003/11/17 07:40:34 Modified: . build.properties src/webapp sitemap.xmap tools/src/anttasks XConfToolTask.java Added: src/confpatch mount-table.xmap Log: Fixing the xconf task so that it can resolve properties (with replace-properties attribute set to true in patch file) Adding a patch to /src/confpatch to patch the mount-table matcher into the sitemap, using the ${build.mounttable} variable from build.properties. Revision Changes Path 1.28 +1 -0 cocoon-2.1/build.properties Index: build.properties =================================================================== RCS file: /home/cvs/cocoon-2.1/build.properties,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- build.properties 5 Sep 2003 06:13:11 -0000 1.27 +++ build.properties 17 Nov 2003 15:40:33 -0000 1.28 @@ -57,6 +57,7 @@ build.deprecated=${build}/deprecated build.samples=${build}/samples build.temp=${build}/temp +build.mounttable=../../mount-table.xml build.docs.loglevel=ERROR build.docs.printer.loglevel=ERROR 1.41 +1 -9 cocoon-2.1/src/webapp/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/cocoon-2.1/src/webapp/sitemap.xmap,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- sitemap.xmap 13 Nov 2003 18:10:03 -0000 1.40 +++ sitemap.xmap 17 Nov 2003 15:40:33 -0000 1.41 @@ -559,14 +559,6 @@ - - - - - 1.9 +46 -2 cocoon-2.1/tools/src/anttasks/XConfToolTask.java Index: XConfToolTask.java =================================================================== RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/XConfToolTask.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XConfToolTask.java 21 Jun 2003 06:53:55 -0000 1.8 +++ XConfToolTask.java 17 Nov 2003 15:40:33 -0000 1.9 @@ -58,7 +58,9 @@ import org.apache.xpath.XPathAPI; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; +import org.w3c.dom.DOMException; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NodeList; import org.w3c.dom.Node; import org.xml.sax.SAXException; @@ -212,6 +214,8 @@ throw new BuildException("TransformerException: "+e); } catch (SAXException e) { throw new BuildException("SAXException: "+e); + } catch (DOMException e) { + throw new BuildException("DOMException:" +e); } catch (ParserConfigurationException e) { throw new BuildException("ParserConfigurationException: "+e); } catch (UnknownHostException e) { @@ -233,7 +237,7 @@ private boolean patch(final Document configuration, final Document component, String file) - throws TransformerException, IOException { + throws TransformerException, IOException, DOMException { // Check to see if Document is an xconf-tool document Element elem = component.getDocumentElement(); @@ -337,6 +341,11 @@ log("Processing: "+file); NodeList componentNodes = component.getDocumentElement().getChildNodes(); + String replacePropertiesStr = component.getDocumentElement().getAttribute("replace-properties"); + + boolean replaceProperties = "yes".equalsIgnoreCase(replacePropertiesStr) || + "true".equalsIgnoreCase(replacePropertiesStr); + if (this.addComments) { root.appendChild(configuration.createComment("..... Start configuration from '"+basename+"' ")); root.appendChild(configuration.createTextNode(NL)); @@ -345,6 +354,9 @@ Node node = configuration.importNode(componentNodes.item(i), true); + if (replaceProperties) { + replaceProperties(node); + } if (before==null) { root.appendChild(node); } else { @@ -356,6 +368,38 @@ root.appendChild(configuration.createTextNode(NL)); } return true; + } + } + + private void replaceProperties(Node n) throws DOMException { + + NamedNodeMap attrs = n.getAttributes(); + if (attrs!=null) { + for (int i = 0; i< attrs.getLength(); i++) { + Node attr = attrs.item(i); + attr.setNodeValue(getProject().replaceProperties(attr.getNodeValue())); + } + } + switch (n.getNodeType()) { + case Node.ATTRIBUTE_NODE: + case Node.CDATA_SECTION_NODE: + case Node.TEXT_NODE: { + n.setNodeValue(getProject().replaceProperties(n.getNodeValue())); + break; + } + case Node.DOCUMENT_NODE: + case Node.DOCUMENT_FRAGMENT_NODE: + case Node.ELEMENT_NODE: { + Node child = n.getFirstChild(); + while (child != null) { + replaceProperties(child); + child = child.getNextSibling(); + } + break; + } + default: { + // ignore all other node types + } } } 1.1 cocoon-2.1/src/confpatch/mount-table.xmap Index: mount-table.xmap ===================================================================