@@ -37,10 +37,10 @@ public class DTDValidator
3737 extends DTDValidatorBase
3838{
3939 /*
40- ///////////////////////////////////////
40+ ///////////////////////////////////////////////////////////////////////
4141 // Configuration
42- ///////////////////////////////////////
43- */
42+ ///////////////////////////////////////////////////////////////////////
43+ */
4444
4545 /**
4646 * Determines if identical problems (definition of the same element,
@@ -51,10 +51,10 @@ public class DTDValidator
5151 protected boolean mReportDuplicateErrors = false ;
5252
5353 /*
54- ///////////////////////////////////////
54+ ///////////////////////////////////////////////////////////////////////
5555 // Id/idref state
56- ///////////////////////////////////////
57- */
56+ ///////////////////////////////////////////////////////////////////////
57+ */
5858
5959 /**
6060 * Information about declared and referenced element ids (unique
@@ -63,10 +63,10 @@ public class DTDValidator
6363 protected ElementIdMap mIdMap = null ;
6464
6565 /*
66- ///////////////////////////////////////////
66+ ///////////////////////////////////////////////////////////////////////
6767 // Element def/spec/validator stack, state
68- ///////////////////////////////////////////
69- */
68+ ///////////////////////////////////////////////////////////////////////
69+ */
7070
7171 /**
7272 * Stack of validators for open elements
@@ -79,26 +79,26 @@ public class DTDValidator
7979 */
8080 protected BitSet mCurrSpecialAttrs = null ;
8181
82- boolean mCurrHasAnyFixed = false ;
82+ protected boolean mCurrHasAnyFixed = false ;
8383
8484 /*
85- ///////////////////////////////////////
85+ ///////////////////////////////////////////////////////////////////////
8686 // Temporary helper objects
87- ///////////////////////////////////////
88- */
87+ ///////////////////////////////////////////////////////////////////////
88+ */
8989
9090 /**
9191 * Reusable lazily instantiated BitSet; needed to keep track of
9292 * missing 'special' attributes (required ones, ones with default
9393 * values)
9494 */
95- BitSet mTmpSpecialAttrs ;
95+ protected BitSet mTmpSpecialAttrs ;
9696
9797 /*
98- ///////////////////////////////////////
98+ ///////////////////////////////////////////////////////////////////////
9999 // Life-cycle
100- ///////////////////////////////////////
101- */
100+ ///////////////////////////////////////////////////////////////////////
101+ */
102102
103103 public DTDValidator (DTDSubset schema , ValidationContext ctxt , boolean hasNsDefaults ,
104104 Map <PrefixedName ,DTDElement > elemSpecs , Map <String ,EntityDecl > genEntities )
@@ -111,10 +111,10 @@ public DTDValidator(DTDSubset schema, ValidationContext ctxt, boolean hasNsDefau
111111 public final boolean reallyValidating () { return true ; }
112112
113113 /*
114- ///////////////////////////////////////
114+ ///////////////////////////////////////////////////////////////////////
115115 // XMLValidator implementation
116- ///////////////////////////////////////
117- */
116+ ///////////////////////////////////////////////////////////////////////
117+ */
118118
119119 //public XMLValidationSchema getSchema();
120120
@@ -208,11 +208,10 @@ public String validateAttribute(String localName, String uri,
208208 // Only report error if not already recovering from an error:
209209 if (mCurrElem != null ) {
210210 reportValidationProblem (ErrorConsts .ERR_VLD_UNKNOWN_ATTR ,
211- mCurrElem .toString (), mTmpKey .toString ());
211+ mCurrElem .toString (), mTmpKey .toString ());
212212 }
213- /* [WSTX-190] NPE if we continued (after reported didn't
214- * throw an exception); nothing more to do, let's leave
215- */
213+ // [WSTX-190] NPE if we continued (after reported didn't
214+ // throw an exception); nothing more to do, let's leave
216215 return value ;
217216 }
218217 int index = mAttrCount ++;
@@ -239,21 +238,19 @@ public String validateAttribute(String localName, String uri,
239238
240239 @ Override
241240 public String validateAttribute (String localName , String uri ,
242- String prefix ,
243- char [] valueChars , int valueStart ,
244- int valueEnd )
241+ String prefix ,
242+ char [] valueChars , int valueStart , int valueEnd )
245243 throws XMLStreamException
246244 {
247245 DTDAttribute attr = mCurrAttrDefs .get (mTmpKey .reset (prefix , localName ));
248246 if (attr == null ) {
249247 // Only report error if not already covering from an error:
250248 if (mCurrElem != null ) {
251249 reportValidationProblem (ErrorConsts .ERR_VLD_UNKNOWN_ATTR ,
252- mCurrElem .toString (), mTmpKey .toString ());
250+ mCurrElem .toString (), mTmpKey .toString ());
253251 }
254- /* [WSTX-190] NPE if we continued (after reported didn't
255- * throw an exception); nothing more to do, let's leave
256- */
252+ // [WSTX-190] NPE if we continued (after reported didn't
253+ // throw an exception); nothing more to do, let's leave
257254 return new String (valueChars , valueStart , valueEnd -valueStart );
258255 }
259256 int index = mAttrCount ++;
@@ -278,7 +275,7 @@ public String validateAttribute(String localName, String uri,
278275 }
279276 if (!match ) {
280277 String act = (result == null ) ?
281- new String (valueChars , valueStart , valueEnd ) : result ;
278+ new String (valueChars , valueStart , valueEnd - valueStart ) : result ;
282279 reportValidationProblem ("Value of #FIXED attribute \" " +attr +"\" (element <" +mCurrElem +">) not \" " +exp +"\" as expected, but \" " +act +"\" " );
283280 }
284281 }
@@ -381,9 +378,9 @@ public void validationCompleted(boolean eod) throws XMLStreamException
381378 }
382379
383380 /*
384- ///////////////////////////////////////
381+ ///////////////////////////////////////////////////////////////////////
385382 // Package methods, accessors
386- ///////////////////////////////////////
383+ ///////////////////////////////////////////////////////////////////////
387384 */
388385
389386 @ Override
@@ -395,27 +392,25 @@ protected ElementIdMap getIdMap() {
395392 }
396393
397394 /*
398- ///////////////////////////////////////
395+ ///////////////////////////////////////////////////////////////////////
399396 // Internal methods
400- ///////////////////////////////////////
397+ ///////////////////////////////////////////////////////////////////////
401398 */
402399
403400 protected void checkIdRefs ()
404401 throws XMLStreamException
405402 {
406- /* 02-Oct-2004, TSa: Now we can also check that all id references
407- * pointed to ids that actually are defined
408- */
403+ // 02-Oct-2004, TSa: Now we can also check that all id references
404+ // pointed to ids that actually are defined
409405 if (mIdMap != null ) {
410406 ElementId ref = mIdMap .getFirstUndefined ();
411407 if (ref != null ) { // problem!
412408 reportValidationProblem ("Undefined id '" +ref .getId ()
413- +"': referenced from element <"
414- +ref .getElemName ()+">, attribute '"
415- +ref .getAttrName ()+"'" ,
416- ref .getLocation ());
409+ +"': referenced from element <"
410+ +ref .getElemName ()+">, attribute '"
411+ +ref .getAttrName ()+"'" ,
412+ ref .getLocation ());
417413 }
418414 }
419415 }
420-
421416}
0 commit comments