Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 19791 invoked from network); 10 Oct 2003 07:56:25 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 10 Oct 2003 07:56:25 -0000 Received: (qmail 62667 invoked by uid 500); 10 Oct 2003 07:55:58 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 62502 invoked by uid 500); 10 Oct 2003 07:55:56 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 62487 invoked from network); 10 Oct 2003 07:55:56 -0000 Received: from unknown (HELO out2.smtp.messagingengine.com) (66.111.4.26) by daedalus.apache.org with SMTP; 10 Oct 2003 07:55:56 -0000 Received: from mail.messagingengine.com (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id 724152AC88E for ; Fri, 10 Oct 2003 03:56:06 -0400 (EDT) Received: from 10.202.2.150 ([10.202.2.150] helo=mail.messagingengine.com) by messagingengine.com with SMTP; Fri, 10 Oct 2003 03:56:06 -0400 X-Epoch: 1065772566 X-Sasl-enc: 35cQhkwGIyJH+Qk27y6krw Received: from upaya.co.uk (elfriedeholmes.demon.co.uk [80.177.165.206]) by www.fastmail.fm (Postfix) with ESMTP id 6A0962B57A3 for ; Fri, 10 Oct 2003 03:56:05 -0400 (EDT) Message-ID: <3F8665F4.90009@upaya.co.uk> Date: Fri, 10 Oct 2003 08:55:32 +0100 From: Upayavira User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ant Developers List Subject: Re: Questions: A Cocoon Ant task References: <879A5AD5DD0ED511891F0003473A9B5608FF712F@Z011004> In-Reply-To: <879A5AD5DD0ED511891F0003473A9B5608FF712F@Z011004> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 Jan.Materne@rzf.fin-nrw.de wrote: >Maybe you should have a look at forrest. They provide an ant buildfile to >start the site generation. > > Thanks. But this one will be used by Forrest! At the moment, they just use the task to start Cocoon, whereas this will allow them to call it with , which will give them greater functionality. Thanks though! Regards, Upayavira > >Jan > > > >>-----Original Message----- >>From: Upayavira [mailto:uv@upaya.co.uk] >>Sent: Thursday, October 09, 2003 11:24 AM >>To: Ant Developers List >>Subject: Re: Questions: A Cocoon Ant task >> >> >>Dominique et al, >> >>Thanks for that. That's really helpful. I've got a version coded, and >>I'm almost there... >> >>I've got it reading my XML and parsing it successfully. >> >>And I've managed to create my own class loader, and have that load my >>Cocoon classes, directly from the cocoon/WEB-INF/lib folder. >>Great too. >> >>However, when it starts to dig deeper into Cocoon, I find that it is >>using the Ant classloader in preference to mine - i.e. when asked for >>org.apache.log.Hierarchy, it presents the one from within >>velocity-dep-1.3-dev.jar, which is an Ant jar, not the one >>provided by >>Cocoon. >> >>Any ideas how I can force all classloading between >>loader.setThreadContextLoader() and >>loader.resetThreadContextLoader() to use _my_ classloader, and ignore >>completely Ant's one? >> >>Thanks for your help - I never thought I'd get this far with it - >>*complete* reuse of my configuration code! >> >>Regards, Upayavira >> >>Dominique Devienne wrote: >> >> >> >>>You can use DynamicConfigurator to intercept >>> >>> >>attribute/elements, and build >> >> >>>the DOM tree yourself, which you can then feed to Cocoon's >>> >>> >>CLI I guess. >> >> >>>The code below should get you a leg up. Provided with no warranties >>>whatsoever ;-) I wrote this a long time ago, on a weekend, >>> >>> >>with little Ant >> >> >>>experience. --DD >>> >>>package com.lgc.buildmagic; >>> >>>import java.io.IOException; >>>import java.io.ByteArrayOutputStream; >>> >>>import org.w3c.dom.Node; >>>import org.w3c.dom.Element; >>>import org.w3c.dom.Document; >>>import org.w3c.dom.DocumentFragment; >>>import org.w3c.dom.NodeList; >>>import org.w3c.dom.DOMException; >>> >>>import javax.xml.parsers.DocumentBuilder; >>>import javax.xml.parsers.DocumentBuilderFactory; >>>import javax.xml.parsers.ParserConfigurationException; >>> >>>import org.apache.tools.ant.Project; >>>import org.apache.tools.ant.BuildException; >>>import org.apache.tools.ant.DynamicConfigurator; >>> >>>import org.apache.tools.ant.types.DataType; >>>//import org.apache.tools.ant.util.DOMElementWriter; >>> >>>/** >>>* Base class for those classes that can appear inside the build file >>>* as stand alone data types. >>>* >>>*

My very first data type ;-)

>>>* >>>* @author Dominique Devienne >>>*/ >>>public class XmlFragment >>> extends DataType >>> implements DynamicConfigurator { >>> >>> /** >>> * A dyna'tor for each element. >>> */ >>> private static class ElementWrapper >>> implements DynamicConfigurator { >>> >>> /** The XML DOM node */ >>> private Node _node; >>> >>> /** Instantiate a root wrapper */ >>> private ElementWrapper(Node node) { >>> _node = node; // Could be a Document or DocumentFragment >>> } >>> >>> /** Instantiate a child wrapper */ >>> private ElementWrapper(Node parent, String childName) { >>> Document document = parent.getOwnerDocument(); >>> if (document == null) { >>> document = (Document)parent; // Node is the document! >>> } >>> _node = document.createElement(childName); >>> parent.appendChild(_node); >>> } >>> >>> public String toString() { >>> ByteArrayOutputStream ostream = new >>> >>> >>ByteArrayOutputStream(); >> >> >>> // This will fail, since the DocFragment is not >>> >>> >>an Element! >> >> >>> // DOMElementWriter needs to be fixed to take a >>> >>> >>node, not an >> >> >>>Element. >>> try { >>> new DOMElementWriter().write(_node, ostream); >>> return ostream.toString(); >>> } >>> catch (IOException e) { >>> throw new BuildException(e); >>> } >>> } >>> >>> >>> // >>> // interface DynamicConfigurator >>> // >>> >>> public void setDynamicAttribute(String name, String value) >>> throws BuildException { >>> // Never called for anything by Element wrappers >>> Element element = (Element)_node; >>> element.setAttribute(name, value); >>> } >>> >>> public Object createDynamicElement(String name) >>> throws BuildException { >>> return new ElementWrapper(_node, name); >>> } >>> >>> } // END class XmlFragment.ElementWrapper >>> >>> >>> private DocumentFragment _fragment; >>> private ElementWrapper _wrapper; >>> >>> /** >>> * Instanciate a new DOM document fragment wrapped in an >>> >>> >>Ant data type. >> >> >>> */ >>> public XmlFragment() { >>> try { >>> DocumentBuilder builder = >>>DocumentBuilderFactory.newInstance().newDocumentBuilder(); >>> _fragment = >>> >>> >>builder.newDocument().createDocumentFragment(); >> >> >>> _wrapper = new ElementWrapper(_fragment); >>> } >>> catch (ParserConfigurationException e) { >>> throw new BuildException(e); >>> } >>> } >>> >>> /** >>> * Sets the name of the top-level DOM node, the xml >>> >>> >>fragment, to use. >> >> >>> * >>> * @param name the xml fragment node name. Defaults to >>> >>> >>"xmlfragment". >> >> >>> public void setName(String name) { >>> _wrapper._tagname = name; >>> } >>> */ >>> >>> public String toString() { >>> return _wrapper.toString(); >>> } >>> >>> >>> // >>> // interface DynamicConfigurator >>> // >>> >>> public void setDynamicAttribute(String name, String value) >>> throws BuildException { >>> // The root only supports explicit 'normal' attributes! >>> throw new BuildException("attribute "+name+" not >>> >>> >>supported!"); >> >> >>> } >>> >>> public Object createDynamicElement(String name) >>> throws BuildException { >>> return _wrapper.createDynamicElement(name); >>> } >>> >>>} // END class XmlFragment >>> >>> >>> >>> >>> >>>>-----Original Message----- >>>>From: Upayavira [mailto:uv@upaya.co.uk] >>>>Sent: Wednesday, October 08, 2003 1:49 PM >>>>To: dev@ant.apache.org >>>>Subject: Questions: A Cocoon Ant task >>>> >>>>I am attempting to craft an Ant task for Apache Cocoon's >>>> >>>> >>command line >> >> >>>>interface. >>>> >>>>Cocoon's CLI can be configured with an XML xconf file. I >>>> >>>> >>want to move >> >> >>>>this configuration information into the Ant build script itself. >>>> >>>>Is there any way I can share the code to interpret this XML >>>>configuration information between Cocoon and Ant? In >>>> >>>> >>Cocoon's CLI I use >> >> >>>>a DOM to parse the XML, but in Ant I seem to have to create >>>> >>>> >>objects for >> >> >>>>nested elements, and have Ant handle it using introspection. >>>> >>>>Is there any other way, or do I just have to accept that I've got to >>>>maintain two sets of code - one for use from the command >>>> >>>> >>line, and one >> >> >>>>from Ant? >>> >>> >>>>I hope I'm clear enough. >>>> >>>>Thanks for any help. >>>> >>>>Regards, >>>> >>>>Upayavira >>>> >>>> >>>> >>>> >>>--------------------------------------------------------------------- >>>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org >>>For additional commands, e-mail: dev-help@ant.apache.org >>> >>> >>> >>> >>> >>> >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org >>For additional commands, e-mail: dev-help@ant.apache.org >> >> >> > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org