Bug 37286 - MacroDef Element Namespaces
Summary: MacroDef Element Namespaces
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-28 05:43 UTC by Nicole Tedesco
Modified: 2008-11-24 03:58 UTC (History)
0 users



Attachments
Partial Ant 1.6.5 schema (347.12 KB, text/xml)
2005-10-28 05:46 UTC, Nicole Tedesco
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicole Tedesco 2005-10-28 05:43:31 UTC
I personally would like a schema for Ant build files.  Sure, no schema could
ever be complete for Ant but a "good enough" schema could do in just about all
cases that most people will encounter and schema extensions may be able to fill
in the rest.  However, I could write a schema today if characteristics such as
the "name" attribute of the "element" element in MacroDefs could be specified
against a specific namespace.  If I could do that then I could write a schema
with lots of "any" elements validating against ##other namespaces and I could
make most of my build files validate quite cleanly while remaining quite flexible.

Any thoughts?
Comment 1 Nicole Tedesco 2005-10-28 05:46:17 UTC
Created attachment 16825 [details]
Partial Ant 1.6.5 schema

This partial Ant 1.6.5 schema relies on ##other namespacing and schema
extensions to enable flexibility
Comment 2 Nicole Tedesco 2005-10-28 21:57:30 UTC
I've thought about this a little more:

1. First get macrodef and taskdef to actually propagate the namespace down to de
nova attributes and elements.

2. Allow the attributes and elements in the *def body to be able to referred to
with the namespace prefix that had been previously mapped.  For instance:

<project
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:foo="http://www.foo.com/ant" >

...

<target name="-init-macrodef-javac" depends="-init">
	<macrodef name="javac" uri="http://www.foo.com/ant">
		<attribute name="srcdir" default="${src.dir}"/>
		<attribute name="destdir" default="${build.classes.dir.real}"/>
		<attribute name="classpath"
default="${javac.classpath}:${j2ee.platform.classpath}"/>
		<attribute name="debug" default="${javac.debug}"/>
		<element name="customize" optional="true"/>
		<sequential>
			<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}"
deprecation="${javac.deprecation}" source="${javac.source}"
target="${javac.target}" includeantruntime="false">
				<classpath>
					<path path="@{classpath}"/>
				</classpath>
				<compilerarg line="${javac.compilerargs}"/>
				<foo:customize/>
			</javac>
		</sequential>
	</macrodef>
</target>

Not only does this help with schema development, but it also makes things a
little more readable (e.g., easily notice the difference between elements that
are there by original definition and those that were added).

If there is anything I can do (e.g., help code development) to make this happen
ASAP (that is, if is indeed a desirable feature) then I'll be glad to chip in.

Nicole Tedesco
nicole@tedesco.name
phlorgian@hotmail.com