SourceForge.net Logo
NSFixupFilter.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2008
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004-2008
5  * Oracle. All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * $Id$
20  */
21 
22 #ifndef _NSFIXUPFILTER_HPP
23 #define _NSFIXUPFILTER_HPP
24 
26 
28 
29 class XQILLA_API NSFixupFilter : public EventFilter
30 {
31 public:
33  ~NSFixupFilter();
34 
35  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding);
36  virtual void endDocumentEvent();
37  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname);
38  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
39  const XMLCh *typeURI, const XMLCh *typeName);
40  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
41  const XMLCh *typeURI, const XMLCh *typeName);
42  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri);
43 
44 private:
45  struct ElemEntry {
46  void set(const XMLCh *p, ElemEntry *pr)
47  { prefix = p; prev = pr; }
48 
49  const XMLCh *prefix;
50  ElemEntry *prev;
51  };
52 
53  struct NSEntry {
54  void set(const XMLCh *p, const XMLCh *u, unsigned int l, NSEntry *pr)
55  { prefix = p; uri = u; level = l; prev = pr; }
56 
57  const XMLCh *prefix;
58  const XMLCh *uri;
59  unsigned int level;
60 
61  NSEntry *prev;
62  };
63 
64  NSEntry *findPrefix(const XMLCh *prefix);
66  bool definePrefix(const XMLCh *&prefix, const XMLCh *uri, bool attr = false, bool redefine = true);
67 
69  unsigned int level_;
70  ElemEntry *elements_;
71  NSEntry *namespaces_;
72 };
73 
74 #endif