2 * Copyright 2001-2007 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.
20 * Representing XML namespace attributes
24 #include "Namespace.h"
26 using namespace xmltooling;
28 using xercesc::XMLString;
30 Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix, bool alwaysDeclare) : m_pinned(alwaysDeclare)
36 setNamespacePrefix(prefix);
39 Namespace::~Namespace()
42 XMLString::release(&m_uri);
43 XMLString::release(&m_prefix);
47 void Namespace::setNamespacePrefix(const XMLCh* prefix)
56 XMLString::release(&m_prefix);
57 m_prefix=XMLString::replicate(prefix);
61 void Namespace::setNamespaceURI(const XMLCh* uri)
70 XMLString::release(&m_uri);
71 m_uri=XMLString::replicate(uri);
76 Namespace::Namespace(const Namespace& src)
78 m_uri=XMLString::replicate(src.getNamespaceURI());
79 m_prefix=XMLString::replicate(src.getNamespacePrefix());
80 m_pinned=src.alwaysDeclare();
83 Namespace& Namespace::operator=(const Namespace& src)
85 m_uri=XMLString::replicate(src.getNamespaceURI());
86 m_prefix=XMLString::replicate(src.getNamespacePrefix());
87 m_pinned=src.alwaysDeclare();
91 bool xmltooling::operator==(const Namespace& op1, const Namespace& op2)
95 return (XMLString::equals(op1.getNamespaceURI(),op2.getNamespaceURI()) &&
96 XMLString::equals(op1.getNamespacePrefix(),op2.getNamespacePrefix()));
100 bool xmltooling::operator<(const Namespace& op1, const Namespace& op2)
102 int i=XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI());
106 return (XMLString::compareString(op1.getNamespacePrefix(),op2.getNamespacePrefix())<0);