XFormsInstance.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. XFormsInstance.prototype = new XFormsElement;
  2. function XFormsInstance (strParentId, strId, bPreserveWhitespace, strTag, strEncoding, strVersion, strXml)
  3. {
  4. if (!strId)
  5. {
  6. return;
  7. }
  8. XFormsElement.call(this, strParentId, strId, strTag);
  9. strXml = this._restore(strXml);
  10. /**
  11. * Attribute
  12. */
  13. this.attribute["preservewhitespace"] = bPreserveWhitespace;
  14. /**
  15. * Property
  16. */
  17. this.preserveWhitespace = bPreserveWhitespace;
  18. this.encoding = strEncoding;
  19. this.documentElement = XmlLib.loadXMLFromString(strXml);
  20. this.root = this.documentElement.firstChild;
  21. this.version = strVersion;
  22. this.xml = strXml;
  23. this.m_docClone;
  24. /**
  25. * Model에 추가한다.
  26. */
  27. XFormsModel.appendInstance(strId, this, strParentId);
  28. };
  29. XFormsInstance.prototype.getXml = function ()
  30. {
  31. return this.xml = XmlLib.serializeToString(this.documentElement);
  32. };
  33. XFormsInstance.prototype.getAbility = function ()
  34. {
  35. return EA_HAS_DOM;
  36. };
  37. /**
  38. * 인스턴스 초기화에 관한일을 정의한다.
  39. * @return
  40. */
  41. XFormsInstance.prototype.synchronize = function ()
  42. {
  43. // documentElement과 xml을 동기화 시킨다.
  44. this.xml = XmlLib.serializeToString(this.documentElement);
  45. this.root = this.documentElement.firstChild;
  46. };
  47. XFormsInstance.prototype.createAttribute = function ()
  48. {
  49. };
  50. XFormsInstance.prototype.createElement = function (strName)
  51. {
  52. return this.documentElement.createElement(strName);
  53. };
  54. XFormsInstance.prototype.createNode = function (strType, strName, strNamespace)
  55. {
  56. var xnNode = null;
  57. if ("element" == strType)
  58. {
  59. xnNode = this.createElement(strName);
  60. }
  61. else if ("attribute" == strType)
  62. {
  63. xnNode = this.createAttribute(strName);
  64. }
  65. // TODO namespaceURI
  66. return xnNode;
  67. };
  68. XFormsInstance.prototype.getElementsByTagName = function ()
  69. {
  70. };
  71. XFormsInstance.prototype.getXPathString = function ()
  72. {
  73. };
  74. XFormsInstance.prototype.load = function ()
  75. {
  76. };
  77. XFormsInstance.prototype.loadXML = function (strXml)
  78. {
  79. this.xml = strXml;
  80. this.documentElement = XmlLib.loadXMLFromString(strXml);
  81. this.root = this.documentElement.firstChild;
  82. };
  83. XFormsInstance.prototype.selectNodes = function (strXPath)
  84. {
  85. return XmlLib.selectNodes(this.documentElement, strXPath);
  86. };
  87. XFormsInstance.prototype.selectNodesXml = function (strXPath)
  88. {
  89. var strNode = "";
  90. var xnNodeList = XmlLib.selectNodes(this.documentElement, strXPath);
  91. if (null != xnNodeList)
  92. {
  93. for (var i=0; i< xnNodeList.length; i++)
  94. {
  95. strNode += XmlLib.serializeToString(xnNodeList.item(i));
  96. }
  97. }
  98. return strNode;
  99. };
  100. XFormsInstance.prototype.selectSingleNode = function (strXPath)
  101. {
  102. return XmlLib.selectSingleNode(this.documentElement, strXPath);
  103. };
  104. XFormsInstance.prototype.cloneInstances = function ()
  105. {
  106. };
  107. XFormsInstance.prototype._restore = function (strXml)
  108. {
  109. strXml = strXml.split("\_\_TF\_N").join("\\n");
  110. strXml = strXml.split("\_\_TF\_T").join("\\t");
  111. strXml = strXml.split("\_\_TF\_R").join("\\r");
  112. return strXml;
  113. };
  114. // TODO createChild 구현중 2011. 03. 15. 박현우 /////////////////////////////////////////////////////////////////////////////////////
  115. //XFormsInstance.create = function (strParentId, clAttribute, strStyle)
  116. //{
  117. // // 메인노드 생성
  118. // var xnInsatance = XFormsInstance.createMainNode(clAttribute);
  119. //// var xnParent = document.getElementById("HE_"+strParentId);
  120. //// xnParent.appendChild(xnInsatance);
  121. ////
  122. //// // 하위노드 생성
  123. //// xnInsatance = XFormsInstance.createSubNodes(xnInsatance, clAttribute);
  124. //
  125. // // object 생성
  126. // return XFormsInstance.createObject(strParentId, xnInsatance, clAttribute, strStyle);
  127. //};
  128. //
  129. //XFormsInstance.createMainNode = function (clAttribute)
  130. //{
  131. //
  132. //// return xnInstance;
  133. //};
  134. //
  135. //XFormsInstance.createObject = function (strParentId, xnInstance, clAttribute, strStyle)
  136. //{
  137. // var strId = "";
  138. // var bPreserveWhiteSpace = false;
  139. // var strEncoding = "";
  140. // var strVersion = "";
  141. // var strXml = "";
  142. // var strUserDefineAttrib = "";
  143. //
  144. // for (var i=0; i<clAttribute.count(); i++)
  145. // {
  146. // var strAttributeName = clAttribute.keys()[i];
  147. // switch (strAttributeName)
  148. // {
  149. // case "id" :
  150. // {
  151. // strId = clAttribute.item(strAttributeName);
  152. // break;
  153. // }
  154. // case "preservewhitespace" :
  155. // {
  156. // if ("true" == clAttribute.item(strAttributeName))
  157. // {
  158. // bPreserveWhiteSpace = true;
  159. // }
  160. // break;
  161. // }
  162. // case "encoding" :
  163. // {
  164. // strEncoding = clAttribute.item(strAttributeName);
  165. // break;
  166. // }
  167. // case "id" :
  168. // {
  169. // break;
  170. // }
  171. // case "version" :
  172. // {
  173. // strVersion = clAttribute.item(strAttributeName);
  174. // break;
  175. // }
  176. // case "xml" :
  177. // {
  178. // strXml = clAttribute.item(strAttributeName);
  179. // break;
  180. // }
  181. // }
  182. // }
  183. // var xnInstance = new XFormsInstance(strParentId, strId, bPreserveWhiteSpace, "xforms:instance", strEncoding, strVersion, strXml, strUserDefineAttrib);
  184. // return xnInstance;
  185. //};
  186. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////