KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > dv > dtd > XML11NMTOKENDatatypeValidator


1 /*
2  * Copyright 1999-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.dv.dtd;
18
19 import org.apache.xerces.impl.dv.*;
20 import org.apache.xerces.util.XML11Char;
21
22 /**
23  * NMTOKEN datatype validator for NMTokens from XML 1.1.
24  *
25  * @xerces.internal
26  *
27  * @author Jeffrey Rodriguez, IBM
28  * @author Sandy Gao, IBM
29  * @author Neil Graham, IBM
30  *
31  * @version $Id: XML11NMTOKENDatatypeValidator.java,v 1.3 2004/10/06 14:56:51 mrglavas Exp $
32  */

33 public class XML11NMTOKENDatatypeValidator extends NMTOKENDatatypeValidator {
34
35     // construct a NMTOKEN datatype validator
36
public XML11NMTOKENDatatypeValidator() {
37         super();
38     }
39
40     /**
41      * Checks that "content" string is valid NMTOKEN value.
42      * If invalid a Datatype validation exception is thrown.
43      *
44      * @param content the string value that needs to be validated
45      * @param context the validation context
46      * @throws InvalidDatatypeException if the content is
47      * invalid according to the rules for the validators
48      * @see InvalidDatatypeValueException
49      */

50     public void validate(String JavaDoc content, ValidationContext context) throws InvalidDatatypeValueException {
51         if (!XML11Char.isXML11ValidNmtoken(content)) {
52            throw new InvalidDatatypeValueException("NMTOKENInvalid", new Object JavaDoc[]{content});
53        }
54    }
55
56 } // class XML11NMTOKENDatatypeValidator
57

58
Popular Tags