bodewig 01/03/09 01:23:51
Modified: . WHATSNEW
src/main/org/apache/tools/ant/taskdefs AntStructure.java
Log:
Make <antstructure> deal with EnumeratedAttribute attributes whose
values don't match the NMTOKEN production.
Revision Changes Path
1.80 +2 -0 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- WHATSNEW 2001/03/09 09:07:35 1.79
+++ WHATSNEW 2001/03/09 09:23:50 1.80
@@ -19,6 +19,8 @@
* <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
===========================================
1.10 +34 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
Index: AntStructure.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AntStructure.java 2001/01/03 14:18:29 1.9
+++ AntStructure.java 2001/03/09 09:23:51 1.10
@@ -256,7 +256,9 @@
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("(");
@@ -290,5 +292,36 @@
}
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;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]