1 16 17 package org.apache.xerces.impl.dv.xs; 18 19 import org.apache.xerces.impl.dv.InvalidDatatypeValueException; 20 import org.apache.xerces.util.XMLChar; 21 import org.apache.xerces.impl.dv.ValidationContext; 22 23 33 public class IDDV extends TypeValidator{ 34 35 public short getAllowedFacets(){ 36 return (XSSimpleTypeDecl.FACET_LENGTH | XSSimpleTypeDecl.FACET_MINLENGTH | XSSimpleTypeDecl.FACET_MAXLENGTH | XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_WHITESPACE ); 37 } 38 39 public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException { 40 if (!XMLChar.isValidNCName(content)) { 41 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{content, "NCName"}); 42 } 43 return content; 44 } 45 46 public void checkExtraRules(Object value, ValidationContext context) throws InvalidDatatypeValueException { 47 String content = (String )value; 48 if (context.isIdDeclared(content)) 49 throw new InvalidDatatypeValueException("cvc-id.2", new Object []{content}); 50 context.addId(content); 51 } 52 } | Popular Tags |