Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


XalanQName.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XALANQNAME_HEADER_GUARD_1357924680)
19 #define XALANQNAME_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base header file. Must be first.
25 
26 
27 
31 
32 
33 
35 
36 
37 
40 
41 
42 
45 
46 
47 
48 XALAN_CPP_NAMESPACE_BEGIN
49 
50 
51 
52 class XalanElement;
53 class XPathEnvSupport;
54 
55 
56 
57 /**
58  * Class to represent a qualified name. The name of an internal XSLT object,
59  * specifically a named template (see [7 Named Templates]), a mode (see [6.7 Modes]),
60  * an attribute set (see [8.1.4 Named Attribute Sets]), a key (see [14.2 Keys]),
61  * a locale (see [14.3 Number Formatting]), a variable or a parameter (see
62  * [12 Variables and Parameters]) is specified as a QName. If it has a prefix,
63  * then the prefix is expanded into a URI reference using the namespace declarations
64  * in effect on the attribute in which the name occurs. The expanded name
65  * consisting of the local part of the name and the possibly null URI reference
66  * is used as the name of the object. The default namespace is not used for
67  * unprefixed names.
68  */
69 
71 {
72 public:
73 
78 
79  /**
80  * Construct an empty XalanQName.
81  *
82  */
83  explicit
85  {
86  }
87 
88  virtual
90  {
91  }
92 
94  {
95  }
96 
97  /**
98  * Retrieve the local part of qualified name.
99  *
100  * @return local part string
101  */
102  virtual const XalanDOMString&
103  getLocalPart() const = 0;
104 
105  /**
106  * Retrieve the namespace of qualified name.
107  *
108  * @return namespace string
109  */
110  virtual const XalanDOMString&
111  getNamespace() const = 0;
112 
113  /**
114  * Determine if the qualified name is valid.
115  *
116  * @return true if the instance is a valid QName, false if not.
117  */
118  bool
119  isValid() const
120  {
121  return isValidNCName(getLocalPart());
122  }
123 
124  /**
125  * Whether the qualified name is empty.
126  *
127  * @return true if namespace and local part are both empty
128  */
129  bool
130  isEmpty() const
131  {
132  return getNamespace().empty() && getLocalPart().empty();
133  }
134 
135  /**
136  * Override equals and agree that we're equal if the passed object is a
137  * string and it matches the name of the arg.
138  *
139  * @param theRHS namespace to compare
140  * @return true if namespace and local part are both empty
141  */
142  bool
143  equals(const XalanQName& theRHS) const
144  {
145  // Note that we do not use our member variables here. See
146  // class QNameReference for details...
147  return getLocalPart() == theRHS.getLocalPart() &&
148  getNamespace() == theRHS.getNamespace();
149  }
150 
151  /**
152  * Format the QName using the notation "{namespace-uri}local-part" or
153  * "local-part" if the namespace URI is empty. The result is appended
154  * to the provided string.
155  *
156  * @param theString The string to format with the
157  * @return A reference to the parameter.
158  */
160  format(XalanDOMString& theString) const;
161 
162  size_t
163  hash() const
164  {
165  return getLocalPart().hash() % (getNamespace().hash() + 1);
166  }
167 
169  {
170  public:
171 
172  /**
173