Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / soap / impl / SOAPSchemaValidators.cpp
1 /**
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.
6  *
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
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 /**
22  * SOAPSchemaValidators.cpp
23  * 
24  * Schema validators for SOAP schema.
25  */
26
27 #include "internal.h"
28 #include "exceptions.h"
29 #include "soap/SOAP.h"
30 #include "validation/Validator.h"
31 #include "validation/ValidatorSuite.h"
32
33 using namespace soap11;
34 using namespace xmltooling;
35 using namespace std;
36 using xmlconstants::SOAP11ENV_NS;
37
38 namespace {
39
40     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,Faultstring);
41     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,Faultactor);
42
43     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Faultcode);
44         XMLOBJECTVALIDATOR_REQUIRE(Faultcode,Code);
45     END_XMLOBJECTVALIDATOR;
46     
47     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Fault);
48         XMLOBJECTVALIDATOR_REQUIRE(Fault,Faultcode);
49         XMLOBJECTVALIDATOR_REQUIRE(Fault,Faultstring);
50     END_XMLOBJECTVALIDATOR;
51
52     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Envelope);
53         XMLOBJECTVALIDATOR_REQUIRE(Envelope,Body);
54     END_XMLOBJECTVALIDATOR;
55     
56 };
57
58 #define REGISTER_ELEMENT(namespaceURI,cname) \
59     q=QName(namespaceURI,cname::LOCAL_NAME); \
60     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
61     SchemaValidators.registerValidator(q,new cname##SchemaValidator())
62     
63 #define REGISTER_TYPE(namespaceURI,cname) \
64     q=QName(namespaceURI,cname::TYPE_NAME); \
65     XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
66     SchemaValidators.registerValidator(q,new cname##SchemaValidator())
67
68 #define REGISTER_ELEMENT_NOVAL(namespaceURI,cname) \
69     q=QName(namespaceURI,cname::LOCAL_NAME); \
70     XMLObjectBuilder::registerBuilder(q,new cname##Builder());
71     
72 #define REGISTER_TYPE_NOVAL(namespaceURI,cname) \
73     q=QName(namespaceURI,cname::TYPE_NAME); \
74     XMLObjectBuilder::registerBuilder(q,new cname##Builder());
75
76 void soap11::registerSOAPClasses()
77 {
78     QName q;
79     REGISTER_ELEMENT_NOVAL(SOAP11ENV_NS,Body);
80     REGISTER_ELEMENT_NOVAL(nullptr,Detail);
81     REGISTER_ELEMENT(SOAP11ENV_NS,Envelope);
82     REGISTER_ELEMENT(SOAP11ENV_NS,Fault);
83     REGISTER_ELEMENT(nullptr,Faultactor);
84     REGISTER_ELEMENT(nullptr,Faultcode);
85     REGISTER_ELEMENT(nullptr,Faultstring);
86     REGISTER_ELEMENT_NOVAL(SOAP11ENV_NS,Header);
87     REGISTER_TYPE_NOVAL(SOAP11ENV_NS,Body);
88     REGISTER_TYPE_NOVAL(SOAP11ENV_NS,Detail);
89     REGISTER_TYPE(SOAP11ENV_NS,Envelope);
90     REGISTER_TYPE(SOAP11ENV_NS,Fault);
91     REGISTER_TYPE_NOVAL(SOAP11ENV_NS,Header);
92 }