1 // Created on: 2001-08-01
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
18 #include <TCollection_AsciiString.hxx>
19 #include <XmlObjMgt.hxx>
20 #include <XmlObjMgt_Array1.hxx>
21 #include <XmlObjMgt_Document.hxx>
22 #include <XmlObjMgt_DOMString.hxx>
24 IMPLEMENT_DOMSTRING (LowerString, "lower")
25 IMPLEMENT_DOMSTRING (UpperString, "upper")
26 IMPLEMENT_DOMSTRING (IndString, "index")
28 //=======================================================================
29 //function : XmlObjMgt_Array1
30 //purpose : Constructor
31 //=======================================================================
33 XmlObjMgt_Array1::XmlObjMgt_Array1 (const XmlObjMgt_Element& theParent,
34 const XmlObjMgt_DOMString& theName)
35 : myElement (XmlObjMgt::FindChildByName (theParent, theName)),
39 if (myElement != NULL) {
40 if (!myElement.getAttribute(::LowerString()).GetInteger(myFirst))
42 if (!myElement.getAttribute(::UpperString()).GetInteger (myLast))
47 //=======================================================================
48 //function : XmlObjMgt_Array1
49 //purpose : Constructor
50 //=======================================================================
52 XmlObjMgt_Array1::XmlObjMgt_Array1 (const Standard_Integer aFirst,
53 const Standard_Integer aLast)
54 : myFirst (aFirst), myLast (aLast)
57 //=======================================================================
58 //function : CreateArrayElement
59 //purpose : Create DOM_Element representing the array, under 'theParent'
60 //=======================================================================
62 void XmlObjMgt_Array1::CreateArrayElement (XmlObjMgt_Element& theParent,
63 const XmlObjMgt_DOMString& theName)
67 //AGV XmlObjMgt_Document& anOwnerDoc =
68 //AGV (XmlObjMgt_Document&)theParent.getOwnerDocument();
69 XmlObjMgt_Document anOwnerDoc =
70 XmlObjMgt_Document (theParent.getOwnerDocument());
71 myElement = anOwnerDoc.createElement (theName);
72 theParent.appendChild (myElement);
74 myElement.setAttribute (::UpperString(), myLast);
76 myElement.setAttribute (::LowerString(), myFirst);
81 //=======================================================================
84 //=======================================================================
86 void XmlObjMgt_Array1::SetValue
87 (const Standard_Integer theIndex, XmlObjMgt_Element& theValue)
89 myElement.appendChild (theValue);
90 theValue.setAttribute(::IndString(), theIndex);
93 //=======================================================================
96 //=======================================================================
98 XmlObjMgt_Element XmlObjMgt_Array1::Value(const Standard_Integer theIndex) const
100 XmlObjMgt_Element anElem;
102 if (theIndex >= myFirst && theIndex <= myLast)
104 Standard_Integer ind;
105 LDOM_Node aNode = myElement.getFirstChild();
106 while (!aNode.isNull())
108 if (aNode.getNodeType() == LDOM_Node::ELEMENT_NODE)
110 anElem = (XmlObjMgt_Element &) aNode;
111 if (anElem.getAttribute(::IndString()).GetInteger(ind))
115 aNode = aNode.getNextSibling();