Stefan Bodewig wrote:
> Some time back it has been reported that the DTD antstructure
> generates right now is illegal - it contains a + sign in the
> enumeration for the operation attribute of propertyfile's nested entry
> element.
>
> As I read it: An Enumeration consists of things following the Nmtoken
> production and Nmtokens simply cannot contain a + (or a =, ? and many
> other characters for that matter). So there is no way to have an
> enumerated attribute like the incriminated one.
>
> Maybe I'm misreading the XML spec and somebody around here knows
> better than I do. Anybody with a different opinion?
>
> Proposed fix: When building up an enumerated attribute list, check
> wether all parts follow the Nmtoken production. If not, degrade the
> attribute to be of type CDATA.
I found this out a couple weeks ago when trying to use <antstructure> to make
Emacs PSGML mode happy with build.xml's. Try the attached patch, I think it
solves the problem.
-Jesse
--
Jesse Glick <mailto:[EMAIL PROTECTED]>
NetBeans, Open APIs <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR
Index: src/main/org/apache/tools/ant/taskdefs/AntStructure.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java,v
retrieving revision 1.9
diff -u -r1.9 AntStructure.java
--- src/main/org/apache/tools/ant/taskdefs/AntStructure.java 2001/01/03
14:18:29 1.9
+++ src/main/org/apache/tools/ant/taskdefs/AntStructure.java 2001/03/08
20:08:15
@@ -259,14 +259,33 @@
if (values == null || values.length == 0) {
sb.append("CDATA ");
} else {
- sb.append("(");
- for (int i=0; i < values.length; i++) {
- if (i != 0) {
- sb.append(" | ");
+ boolean kosher = true;
+ KOSHER_CHECK:
+ for (int i = 0; i < values.length; i++) {
+ String s = values[i];
+ for (int j = 0; j < s.length(); j++) {
+ char c = s.charAt(j);
+ if (! Character.isLetterOrDigit(c) &&
+ c != '-' && c != '_' &&
+ c != ':' && c != '.') {
+ // Not a valid XML NMTOKEN.
+ kosher = false;
+ break KOSHER_CHECK;
+ }
}
- sb.append(values[i]);
}
- sb.append(") ");
+ if (kosher) {
+ sb.append("(");
+ for (int i=0; i < values.length; i++) {
+ if (i != 0) {
+ sb.append(" | ");
+ }
+ sb.append(values[i]);
+ }
+ sb.append(") ");
+ } else {
+ sb.append("CDATA ");
+ }
}
} catch (InstantiationException ie) {
sb.append("CDATA ");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]