2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file xmltooling/validation/ValidatorSuite.h
24 * Groups of rule checkers of XMLObjects based on type or element name.
27 #ifndef __xmltooling_valsuite_h__
28 #define __xmltooling_valsuite_h__
30 #include <xmltooling/QName.h>
35 #if defined (_MSC_VER)
36 #pragma warning( push )
37 #pragma warning( disable : 4250 4251 )
40 namespace xmltooling {
42 class XMLTOOL_API Validator;
45 * A collection of validators that can be applied to an XMLObject and its children. These collections can represent
46 * usage specific checks, such as those outlined in schemas or profiles of specific XML specifications.
48 * Registered Validators must be stateless. Validators are fetched based on schema type and
49 * element name, in that order.
51 class XMLTOOL_API ValidatorSuite
53 MAKE_NONCOPYABLE(ValidatorSuite);
56 * Creates a new suite.
58 * @param id an identifier for the suite
60 ValidatorSuite(const char* id);
65 * Gets a unique ID for this suite.
67 * @return a unique ID for this suite
72 * Evaluates the registered validators against the given XMLObject and it's children.
74 * @param xmlObject the XMLObject tree to validate
76 * @throws ValidationException thrown if the element tree is not valid
78 void validate(const XMLObject* xmlObject) const;
81 * Registers a new validator for the given key.
83 * @param key the key used to retrieve the validator
84 * @param validator the validator
86 void registerValidator(const QName& key, Validator* validator);
89 * Deregisters validators.
91 * @param key the key for the validators to be deregistered
93 void deregisterValidators(const QName& key);
96 * Unregisters and destroys all registered validators.
98 void destroyValidators();
102 std::multimap<QName,Validator*> m_map;
106 * Validator suite for schema-style structural validation.
108 * This is <strong>NOT</strong> a comprehensive replacement for real
109 * schema validation, but it does basic structural checking of overall
110 * element relationships and some basic attribute presence checking.
112 extern XMLTOOL_API xmltooling::ValidatorSuite SchemaValidators;
116 #if defined (_MSC_VER)
117 #pragma warning( pop )
120 #endif /* __xmltooling_valsuite_h__ */