286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2002,2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.impl.dv.dtd;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.impl.dv.*;
286N/Aimport com.sun.org.apache.xerces.internal.util.XML11Char;
286N/A
286N/A/**
286N/A * <P>IDREFDatatypeValidator - represents the IDREFS
286N/A * attribute type from XML 1.1 recommendation. The
286N/A * Value Space of IDREF is the set of all strings
286N/A * that match the NCName production and have been
286N/A * used in an XML Document as the value of an element
286N/A * or attribute of Type ID. The Lexical space of
286N/A * IDREF is the set of strings that match the NCName
286N/A * production.</P>
286N/A * <P>The Value space of IDREF is scoped to a specific
286N/A * instance document</P>
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @author Jeffrey Rodriguez, IBM
286N/A * @author Sandy Gao, IBM
286N/A * @author Neil Graham, IBM
286N/A *
286N/A */
286N/Apublic class XML11IDREFDatatypeValidator extends IDREFDatatypeValidator {
286N/A
286N/A // construct an IDREF datatype validator
286N/A public XML11IDREFDatatypeValidator() {
286N/A super();
286N/A }
286N/A
286N/A /**
286N/A * Checks that "content" string is valid IDREF value.
286N/A * If invalid a Datatype validation exception is thrown.
286N/A *
286N/A * @param content the string value that needs to be validated
286N/A * @param context the validation context
286N/A * @throws InvalidDatatypeException if the content is
286N/A * invalid according to the rules for the validators
286N/A * @see InvalidDatatypeValueException
286N/A */
286N/A public void validate(String content, ValidationContext context) throws InvalidDatatypeValueException {
286N/A
286N/A //Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
286N/A if(context.useNamespaces()) {
286N/A if (!XML11Char.isXML11ValidNCName(content)) {
286N/A throw new InvalidDatatypeValueException("IDREFInvalidWithNamespaces", new Object[]{content});
286N/A }
286N/A }
286N/A else {
286N/A if (!XML11Char.isXML11ValidName(content)) {
286N/A throw new InvalidDatatypeValueException("IDREFInvalid", new Object[]{content});
286N/A }
286N/A }
286N/A
286N/A context.addIdRef(content);
286N/A
286N/A }
286N/A
286N/A}