question: public static final void isCDataWF ( DOMErrorHandler errorHandler , DOMErrorImpl error , DOMLocatorImpl locator , String datavalue , boolean isXML11Version ) { if ( datavalue == null || ( datavalue . length ( ) == 0 ) ) { return ; } char [ ] dataarray = datavalue . toCharArray ( ) ; int datalength = dataarray . length ; if ( isXML11Version ) { int i = 0 ; while ( i < datalength ) { char c = dataarray [ i ++ ] ; if ( XML11Char . isXML11Invalid ( c ) ) { if ( XMLChar . isHighSurrogate ( c ) && i < datalength ) { char c2 = dataarray [ i ++ ] ; if ( XMLChar . isLowSurrogate ( c2 ) && XMLChar . isSupplemental ( XMLChar . supplemental ( c , c2 ) ) ) { continue ; } } String msg = DOMMessageFormatter . formatMessage ( DOMMessageFormatter . XML_DOMAIN , "InvalidCharInCDSect" , new Object [ ] { Integer . toString ( c , 16 ) } ) ; reportDOMError ( errorHandler , error , locator , msg , DOMError . SEVERITY_ERROR , "wf-invalid-character" ) ; } else if ( c == ']' ) { int count = i ; if ( count < datalength && dataarray [ count ] == ']' ) { while ( ++ count < datalength && dataarray [ count ] == ']' ) { } if ( count < datalength && dataarray [ count ] == '>' ) { String msg = DOMMessageFormatter . formatMessage ( DOMMessageFormatter . XML_DOMAIN , "CDEndInContent" , null ) ; reportDOMError ( errorHandler , error , locator , msg , DOMError . SEVERITY_ERROR , "wf-invalid-character" ) ; } } } } } else { int i = 0 ; while ( i < datalength ) { char c = dataarray [ i ++ ] ; if ( XMLChar . isInvalid ( c ) ) { if ( XMLChar . isHighSurrogate ( c ) && i < datalength ) { char c2 = dataarray [ i ++ ] ; if ( XMLChar . isLowSurrogate ( c2 ) && XMLChar . isSupplemental ( XMLChar . supplemental ( c , c2 ) ) ) { continue ; } } String msg = DOMMessageFormatter . formatMessage ( DOMMessageFormatter . XML_DOMAIN , "InvalidCharInCDSect" , new Object [ ] { Integer . toString ( c , 16 ) } ) ; reportDOMError ( errorHandler , error , locator , msg , DOMError . SEVERITY_ERROR , "wf-invalid-character" ) ; } else if ( c == ']' ) { int count = i ; if ( count < datalength && dataarray [ count ] == ']' ) { while ( ++ count < datalength && dataarray [ count ] == ']' ) { } if ( count < datalength && dataarray [ count ] == '>' ) { String msg = DOMMessageFormatter . formatMessage ( DOMMessageFormatter . XML_DOMAIN , "CDEndInContent" , null ) ; reportDOMError ( errorHandler , error , locator , msg , DOMError . SEVERITY_ERROR , "wf-invalid-character" ) ; } } } } } }
target:  Check if CDATA section is well-formed