From e5eca124f469c0e89654f0fd210347f674995290 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Sat, 12 Jun 2004 16:51:09 +0000 Subject: [PATCH] Allow nested elements of namespaced types to below to the ant default namespace as well as the type's namespace. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276573 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ docs/manual/CoreTypes/namespace.html | 15 ++++++++++++++- .../org/apache/tools/ant/IntrospectionHelper.java | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 49e21d8b9..ce82e1b03 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -49,6 +49,9 @@ Changes that could break older environments: * All exceptions thrown by tasks are now wrapped in a buildexception giving the location in the buildfile of the task. +* Nested elements for namespaced tasks and types may belong to the + Ant default namespace as well as the task's or type's namespace. + Fixed bugs: ----------- diff --git a/docs/manual/CoreTypes/namespace.html b/docs/manual/CoreTypes/namespace.html index 2d51e4540..6bcf9431a 100644 --- a/docs/manual/CoreTypes/namespace.html +++ b/docs/manual/CoreTypes/namespace.html @@ -91,7 +91,8 @@

Namespaces and Nested Elements

-

Almost always in Ant 1.6, elements nested inside a namespaced +

+ Almost always in Ant 1.6, elements nested inside a namespaced element have the same namespace as their parent. So if 'task' in the example above allowed a nested 'config' element, the build file snippet would look like this: @@ -110,6 +111,18 @@ ... </task> +

+ From Ant 1.6.2, elements nested inside a namespaced element may also be + in Ant's default namespace. This means that the following is now allowed: +

+

 <typedef resource="org/example/tasks.properties"
+   uri="http://example.org/tasks"/>
+ <my:task xmlns:my="http://example.org/tasks">
+   <config a="foo" b="bar"/>
+   ...
+ </my:task>
+
+

Namespaces and Attributes

diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index aa50722a8..9c38d98d2 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -604,7 +604,7 @@ public final class IntrospectionHelper implements BuildListener { parentUri = ""; } NestedCreator nc = null; - if (uri.equals(parentUri)) { // || uri.equals("")) { + if (uri.equals(parentUri) || uri.equals("")) { nc = (NestedCreator) nestedCreators.get( name.toLowerCase(Locale.US)); } @@ -775,7 +775,7 @@ public final class IntrospectionHelper implements BuildListener { return ( nestedCreators.containsKey(name.toLowerCase(Locale.US)) - && (uri.equals(parentUri))) // || uri.equals(""))) + && (uri.equals(parentUri) || uri.equals(""))) || DynamicElement.class.isAssignableFrom(bean) || DynamicElementNS.class.isAssignableFrom(bean) || addTypeMethods.size() != 0;