createxml.js
上传用户:yfdli66
上传日期:2010-02-20
资源大小:47k
文件大小:2k
源码类别:

JavaScript

开发平台:

JavaScript

  1. var workflowTag,initialTag,stepsTag,splitsTag,joinsTag;
  2. function createXML() {
  3. //初始化
  4. iniDOM();
  5. //启动
  6. for (var i=0;i<drawCanvas.children.length;i++) {
  7. var childObj = drawCanvas.children[i];
  8. if (childObj.ctlType == CNST_CTLTYPE_INITIAL) {
  9. createInitial(childObj);
  10. }
  11. }
  12. //步骤
  13. for (var i=0;i<drawCanvas.children.length;i++) {
  14. var childObj = drawCanvas.children[i];
  15. if (childObj.ctlType == CNST_CTLTYPE_STEPS) {
  16. createStep(childObj);
  17. }
  18. }
  19. //合并
  20. for (var i=0;i<drawCanvas.children.length;i++) {
  21. var childObj = drawCanvas.children[i];
  22. if (childObj.ctlType == CNST_CTLTYPE_JOINS) {
  23. createJoin(childObj);
  24. }
  25. }
  26. //分支
  27. for (var i=0;i<drawCanvas.children.length;i++) {
  28. var childObj = drawCanvas.children[i];
  29. if (childObj.ctlType == CNST_CTLTYPE_SPLITS) {
  30. createSplit(childObj);
  31. }
  32. }
  33. alert(workflowTag.outerHTML);
  34. }
  35. function iniDOM() {
  36. workflowTag=document.createElement("workflow");
  37. initialTag=document.createElement("initial-actions");
  38. stepsTag=document.createElement("steps");
  39. splitsTag=document.createElement("splits");
  40. joinsTag=document.createElement("joins");
  41. workflowTag.appendChild(initialTag);
  42. workflowTag.appendChild(stepsTag);
  43. workflowTag.appendChild(splitsTag);
  44. workflowTag.appendChild(joinsTag);
  45. }
  46. //启动
  47. function createInitial(childObj) {
  48. //action
  49. var actionTag=document.createElement("action");
  50. actionTag.id = childObj.id; //id
  51. actionTag.name = childObj.ctlName; //name
  52. actionTag.view = childObj.view; //name
  53. initialTag.appendChild(actionTag);
  54. //restrict-to
  55. var restrictTag=document.createElement("restrict-to");
  56. actionTag.appendChild(restrictTag);
  57. //results
  58. var restrictTag=document.createElement("results");
  59. actionTag.appendChild(restrictTag);
  60. }
  61. //步骤
  62. function createStep(childObj) {
  63. //step
  64. var stepTag = document.createElement("step");
  65. stepTag.id = childObj.id; //id
  66. stepTag.name = childObj.ctlName; //name
  67. stepTag.view = childObj.view; //name
  68. stepsTag.appendChild(stepTag);
  69. }
  70. //合并
  71. function createJoin(childObj) {
  72. //step
  73. var joinTag = document.createElement("join");
  74. joinTag.id = childObj.id; //id
  75. joinsTag.appendChild(joinTag);
  76. }
  77. //合并
  78. function createSplit(childObj) {
  79. //step
  80. var splitTag = document.createElement("split");
  81. splitTag.id = childObj.id; //id
  82. splitsTag.appendChild(splitTag);
  83. }