Hi,
Thanks for that Andy. But, you missed the isValidNCName(String) method. Please
find attached patch for the same.
Thanks for committing the patch!.
Cheers,
Rahul.
Sun Microsystems, Inc.
> Andy Clark wrote...
>
> Rahul Srivastava wrote:
> > Please find attached patch for class XMLChar. I have implemented the REVISIT
for
> > NCNAME content validation.
>
> I didn't apply your diff but made the appropriate changes to
> the XMLChar class. Since the only difference between NameStart/
> NCNameStart and Name/NCName characters is the use of the colon,
> it's more efficient to just add the NCName masks when you
> initialize the Name masks and then subtract the NCName masks
> from the colon character. I've attached the diff to show you
> want I mean.
>
> Thanks for the patch!
>
> --
> Andy Clark * IBM, TRL - Japan * [EMAIL PROTECTED]
Index: XMLChar.java
===================================================================
RCS file: /home/cvspublic/xml-xerces/java/src/org/apache/xerces/util/XMLChar.java,v
retrieving revision 1.4
diff -u -w -r1.4 XMLChar.java
--- XMLChar.java 2001/10/19 02:22:16 1.4
+++ XMLChar.java 2001/10/19 05:18:27
@@ -360,7 +360,7 @@
}
// remove ':' from allowable MASK_NCNAME_START and MASK_NCNAME chars
- CHARS[':'] &= ~(MASK_NCNAME_START | MASK_NCNAME);
+ CHARS[nameStartChar[0]] &= ~(MASK_NCNAME_START | MASK_NCNAME);
// set Pubid characters
for (int i = 0; i < pubidChar.length; i++) {
@@ -581,10 +581,20 @@
* @param name string to check
* @return true if name is a valid NCName
*/
- public static boolean isValidNCName(String name) {
- //REVISIT: implement this method!!
- return true;
+ public static boolean isValidNCName(String ncName) {
+ if (ncName.length() == 0)
+ return false;
+ char ch = ncName.charAt(0);
+ if( isNCNameStart(ch) == false)
+ return false;
+ for (int i = 1; i < ncName.length(); i++ ) {
+ ch = ncName.charAt(i);
+ if( isNCName( ch ) == false ){
+ return false;
+ }
}
+ return true;
+ } // isValidNCName(String):boolean
/*
* [7] Nmtoken ::= (NameChar)+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]