Browse Source

Ignore attributes for different uris.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275644 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
929d67e0c9
3 changed files with 39 additions and 2 deletions
  1. +12
    -1
      src/etc/testcases/taskdefs/xmlns.xml
  2. +19
    -1
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  3. +8
    -0
      src/testcases/org/apache/tools/ant/taskdefs/XmlnsTest.java

+ 12
- 1
src/etc/testcases/taskdefs/xmlns.xml View File

@@ -1,5 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project name="test">
<project name="test" xmlns:other="this is the other uri"
other:attr="this should be ignored by ant">


<property name="testcases.dir" location="../../../../build/testcases"/> <property name="testcases.dir" location="../../../../build/testcases"/>


@@ -16,6 +17,16 @@
<test:mytask/> <test:mytask/>
</target> </target>


<target name="other" other:a="this is another attribute">
<echo other:g="abc" message="a message"/>
</target>

<target name="ns.attributes">
<taskdef name="my.echo" classname="org.apache.tools.ant.taskdefs.Echo"
uri="x-uri"/>
<x:my.echo x:message="hello world" xmlns:x="x-uri"/>
</target>

<target name="xmlns.file" xmlns:test="this.is.a.test.uri"> <target name="xmlns.file" xmlns:test="this.is.a.test.uri">
<typedef file="test.antlib.xml" <typedef file="test.antlib.xml"
classpathref="testclasses" classpathref="testclasses"


+ 19
- 1
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -645,9 +645,15 @@ public class ProjectHelper2 extends ProjectHelper {
*/ */


for (int i = 0; i < attrs.getLength(); i++) { for (int i = 0; i < attrs.getLength(); i++) {
String attrUri = attrs.getURI(i);
if (attrUri != null
&& !attrUri.equals("")
&& !attrUri.equals(uri)) {
continue; // Ignore attributes from unknown uris
}
String key = attrs.getLocalName(i); String key = attrs.getLocalName(i);
String value = attrs.getValue(i); String value = attrs.getValue(i);

if (key.equals("default")) { if (key.equals("default")) {
if (value != null && !value.equals("")) { if (value != null && !value.equals("")) {
if (!context.isIgnoringProjectTag()) { if (!context.isIgnoringProjectTag()) {
@@ -797,6 +803,12 @@ public class ProjectHelper2 extends ProjectHelper {
context.addTarget(target); context.addTarget(target);


for (int i = 0; i < attrs.getLength(); i++) { for (int i = 0; i < attrs.getLength(); i++) {
String attrUri = attrs.getURI(i);
if (attrUri != null
&& !attrUri.equals("")
&& !attrUri.equals(uri)) {
continue; // Ignore attributes from unknown uris
}
String key = attrs.getLocalName(i); String key = attrs.getLocalName(i);
String value = attrs.getValue(i); String value = attrs.getValue(i);


@@ -967,6 +979,12 @@ public class ProjectHelper2 extends ProjectHelper {
= new RuntimeConfigurable(task, task.getTaskName()); = new RuntimeConfigurable(task, task.getTaskName());


for (int i = 0; i < attrs.getLength(); i++) { for (int i = 0; i < attrs.getLength(); i++) {
String attrUri = attrs.getURI(i);
if (attrUri != null
&& !attrUri.equals("")
&& !attrUri.equals(uri)) {
continue; // Ignore attributes from unknown uris
}
String name = attrs.getLocalName(i); String name = attrs.getLocalName(i);
String value = attrs.getValue(i); String value = attrs.getValue(i);
// PR: Hack for ant-type value // PR: Hack for ant-type value


+ 8
- 0
src/testcases/org/apache/tools/ant/taskdefs/XmlnsTest.java View File

@@ -88,6 +88,14 @@ public class XmlnsTest extends BuildFileTest {
"Attempt to use a reserved URI ant:notallowed"); "Attempt to use a reserved URI ant:notallowed");
} }


public void testOther() {
expectLog("other", "a message");
}

public void testNsAttributes() {
expectLog("ns.attributes", "hello world");
}
public static class MyTask extends Task { public static class MyTask extends Task {
public void execute() { public void execute() {
log("MyTask called"); log("MyTask called");


Loading…
Cancel
Save