Browse Source

Make <antstructure> deal with EnumeratedAttribute attributes whose

values don't match the NMTOKEN production.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268785 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
e65f093c8c
2 changed files with 36 additions and 1 deletions
  1. +2
    -0
      WHATSNEW
  2. +34
    -1
      src/main/org/apache/tools/ant/taskdefs/AntStructure.java

+ 2
- 0
WHATSNEW View File

@@ -19,6 +19,8 @@ Fixed bugs:
* <javah>'s outputfile attribute will be resolved as relative to the
projects basedir.

* <antstructure> should create a valid DTD for propertyfile.operation.entry

Changes from Ant 1.2 to Ant 1.3
===========================================



+ 34
- 1
src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -256,7 +256,9 @@ public class AntStructure extends Task {
EnumeratedAttribute ea =
(EnumeratedAttribute)type.newInstance();
String[] values = ea.getValues();
if (values == null || values.length == 0) {
if (values == null
|| values.length == 0
|| !areNmtokens(values)) {
sb.append("CDATA ");
} else {
sb.append("(");
@@ -291,4 +293,35 @@ public class AntStructure extends Task {
private void printTail(PrintWriter out) {}

/**
* Does this String match the XML-NMTOKEN production?
*/
protected boolean isNmtoken(String s) {
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
// XXX - we are ommitting CombiningChar and Extender here
if (!Character.isLetterOrDigit(c) &&
c != '.' && c != '-' &&
c != '_' && c != ':') {
return false;
}
}
return true;
}

/**
* Do the Strings all match the XML-NMTOKEN production?
*
* <p>Otherwise they are not suitable as an enumerated attribute,
* for example.</p>
*/
protected boolean areNmtokens(String[] s) {
for (int i = 0; i < s.length; i++) {
if (!isNmtoken(s[i])) {
return false;
}
}
return true;
}

}

Loading…
Cancel
Save