I was thinking about this over french toast and I am -1 as well. It seems too 'special case-ish' to add an API for it, rather than built in something more integrated with the input processing.
On 10/28/01 9:19 AM, "Jason van Zyl" <[EMAIL PROTECTED]> wrote: > On 10/28/01 3:55 AM, "Christian Trutz" <[EMAIL PROTECTED]> wrote: > >> Hello Velocity community, >> >> the folowing little patch is usefull for me ... it allows me accessing an >> XML document via Texen ... > > I'm not sure I quite understand, I would rather not tie Texen to JDOM. > > A feature like this might be useful, but I would probably add a special > handler to the contextProperties processing to look for XML files as text > files are i.e. when something like > > foo.file.contents = bar.txt > > Is seen in the in a properties file specified with the contextProperties > attribute than the text in bar.txt is made available in the template as > $foo. > > Maybe you could do something like: > > foo.xml.file.contents = bar.xml > > to make $foo available as an object representation of the XML file. You > could even use Geir's XMLEasyBean. I don't know if that uses JDOM, maybe you > could use reflection to see if the resources you need are available. > > Right now there are little routines to handle file contents, integers and > booleans in specified contextProperties files. Maybe you could make this a > pluggable mechanism and than you could add whatever you want but I don't > think it's really a good idea to add specific XML file handling to the Texen > task. I'm -1 on the patch. > >> I now Anakia to things better, but in Anakia you has no $generator ... :-( >> >> >> Chris >> >> >> Index: TexenTask.java >> =================================================================== >> RCS file: >> /home/cvspublic/jakarta-velocity/src/java/org/apache/velocity/texen/ant/Texe >> nTask.java,v >> retrieving revision 1.35 >> diff -r1.35 TexenTask.java >> 78a79,81 >>> import org.jdom.input.SAXBuilder; >>> import org.jdom.Document; >>> import org.jdom.JDOMException; >> 84a88 >>> * @author <a mailto:href="[EMAIL PROTECTED]>Christian Trutz</a> >> 156a161,170 >>> * <p> >>> * This is a org.jdom.Document that is fed into the >>> * initial context from a parsed XML file. This >>> * is simply a convenient way to make a parsed >>> * XML file available in the context via $xmlDocument. >>> * </p> >>> */ >>> protected Document contextXML; >>> >>> /** >> 341c355,388 >> < } >> --- >>> } >>> >>> /** >>> * Get the org.jdom.Document that is fed into the >>> * initial context via $xmlDocument. >>> */ >>> public Document getContextXML() >>> { >>> return contextXML; >>> } >>> >>> /** >>> * Set the context XML file >>> * >>> * @param File is an XML file to be parsed, the >>> * org.jdom.Document of this XML file is fed into the >>> * initial context via $xmlDocument. >>> */ >>> public void setContextXML (File xmlFile) throws BuildException >>> { >>> try >>> { >>> SAXBuilder builder = new SAXBuilder(); >>> this.contextXML = builder.build(xmlFile.getCanonicalPath()); >>> } >>> catch (java.io.IOException ioe) >>> { >>> throw new BuildException(ioe); >>> } >>> catch (org.jdom.JDOMException ex) >>> { >>> throw new BuildException(ex); >>> } >>> } >> 570a618 >>> context.put("xmlDocument", getContextXML()); >> >> >> >> -- Geir Magnusson Jr. [EMAIL PROTECTED] System and Software Consulting You're going to end up getting pissed at your software anyway, so you might as well not pay for it. Try Open Source.
