2 * Copyright 2001-2009 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file xmltooling/validation/ValidatorSuite.h
20 * Groups of rule checkers of XMLObjects based on type or element name.
23 #ifndef __xmltooling_valsuite_h__
24 #define __xmltooling_valsuite_h__
26 #include <xmltooling/QName.h>
31 #if defined (_MSC_VER)
32 #pragma warning( push )
33 #pragma warning( disable : 4250 4251 )
36 namespace xmltooling {
38 class XMLTOOL_API Validator;
41 * A collection of validators that can be applied to an XMLObject and its children. These collections can represent
42 * usage specific checks, such as those outlined in schemas or profiles of specific XML specifications.
44 * Registered Validators must be stateless. Validators are fetched based on schema type and
45 * element name, in that order.
47 class XMLTOOL_API ValidatorSuite
49 MAKE_NONCOPYABLE(ValidatorSuite);
52 * Creates a new suite.
54 * @param id an identifier for the suite
56 ValidatorSuite(const char* id);
61 * Gets a unique ID for this suite.
63 * @return a unique ID for this suite
68 * Evaluates the registered validators against the given XMLObject and it's children.
70 * @param xmlObject the XMLObject tree to validate
72 * @throws ValidationException thrown if the element tree is not valid
74 void validate(const XMLObject* xmlObject) const;
77 * Registers a new validator for the given key.
79 * @param key the key used to retrieve the validator
80 * @param validator the validator
82 void registerValidator(const QName& key, Validator* validator);
85 * Deregisters validators.
87 * @param key the key for the validators to be deregistered
89 void deregisterValidators(const QName& key);
92 * Unregisters and destroys all registered validators.
94 void destroyValidators();
98 std::multimap<QName,Validator*> m_map;
102 * Validator suite for schema-style structural validation.
104 * This is <strong>NOT</strong> a comprehensive replacement for real
105 * schema validation, but it does basic structural checking of overall
106 * element relationships and some basic attribute presence checking.
108 extern XMLTOOL_API xmltooling::ValidatorSuite SchemaValidators;
112 #if defined (_MSC_VER)
113 #pragma warning( pop )
116 #endif /* __xmltooling_valsuite_h__ */