1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15 
16 #include "XMLObject.hxx"
17 #include "XMLElement.hxx"
18 #include "XMLNs.hxx"
19 #include "VariableScope.hxx"
20 
21 namespace org_modules_xml
22 {
23 
XMLNs(const XMLObject & _parent,xmlNs * _ns)24 XMLNs::XMLNs(const XMLObject & _parent, xmlNs * _ns): XMLObject(), parent(_parent)
25 {
26     ns = _ns;
27     scope->registerPointers(ns, this);
28     scilabType = XMLNAMESPACE;
29     id = scope->getVariableId(*this);
30 }
31 
XMLNs(const XMLElement & elem,char * prefix,char * href)32 XMLNs::XMLNs(const XMLElement & elem, char *prefix, char *href): XMLObject(), parent(elem)
33 {
34     ns = xmlNewNs(elem.getRealNode(), (const xmlChar *)href, (const xmlChar *)prefix);
35     scope->registerPointers(ns, this);
36     scilabType = XMLNAMESPACE;
37     id = scope->getVariableId(*this);
38 }
39 
~XMLNs()40 XMLNs::~XMLNs()
41 {
42     scope->unregisterPointer(ns);
43     scope->removeId(id);
44 }
45 
getRealXMLPointer() const46 void *XMLNs::getRealXMLPointer() const
47 {
48     return static_cast < void *>(ns);
49 }
50 
getXMLObjectParent() const51 const XMLObject *XMLNs::getXMLObjectParent() const
52 {
53     return &parent;
54 }
55 
toString() const56 const std::string XMLNs::toString() const
57 {
58     std::ostringstream oss;
59 
60     oss << "XML Namespace" << std::endl;
61     oss << "href: " << getHref() << std::endl;
62     oss << "prefix: " << getPrefix();
63 
64     return oss.str();
65 }
66 }
67