| <!DOCTYPE html> |
| <head> |
| <title>RCPTT Documentation Center</title> |
| <meta charset="UTF-8"> |
| <link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/bootstrap.min.css"> |
| <link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/main.css"> |
| <link rel="stylesheet" href="https://www.eclipse.org/rcptt/shared/css/prism.css"> |
| <link rel="icon" href="https://www.eclipse.org/rcptt/shared/img/favicon.ico"> |
| <script src="https://www.eclipse.org/rcptt/shared/js/jquery.min.js"></script> |
| <script src="https://www.eclipse.org/rcptt/shared/js/bootstrap.min.js"></script> |
| <script src="https://www.eclipse.org/rcptt/shared/js/prism.js"></script> |
| <script src="https://www.eclipse.org/rcptt/shared/js/ecl.js"></script> |
| <script> |
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| |
| ga('create', 'UA-39589807-5', 'eclipse.org'); |
| ga('send', 'pageview'); |
| </script> |
| </head> |
| <body> |
| <div id="before-footer"> |
| <header> |
| <nav class="navbar navbar-default navbar-static-top" role="navigation"> |
| <div class="container"> |
| |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <span class="navbar-brand">RCPTT Documentation Center</span> |
| </div> |
| <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> |
| <ul class="nav navbar-nav"> |
| <li class="active" > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/getstarted">User Guide</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/faq/">FAQ</a> |
| </li> |
| <li> |
| <a href="http://eclipse.org/rcptt">Back to RCPTT Main Site</a> |
| </li> |
| <li> |
| <a href="http://eclipse.org">Eclipse.org</a> |
| </li> |
| </ul> |
| </div> |
| </nav> |
| </header> |
| <section class="content"> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-sm-3"> |
| <div class="rcptt-sidebar"> |
| <ul class="nav"> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/getstarted/">Get Started</a> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/testeditor/">Test Case Editor</a> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/controlpanel">Control Panel</a> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/assertions/">Assertions</a> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/">Eclipse Command Language</a> |
| <ul class="nav"> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/new-command-guide/">New ECL Command Guide</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/excel-import-export/">ECL commands for Excel import and export</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/ecl/xml-import-export/">ECL commands for XML import and export</a> |
| </li> |
| </ul> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/">Contexts</a> |
| <ul class="nav"> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/workspace/">Workspace</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/workbench/">Workbench</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/launch/">Launch</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/preferences/">Preferences</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/parameters/">Parameters</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/group/">Group</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/folder/">Folder</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/default/">Default</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/super/">Super</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/contexts/ecl/">ECL Script</a> |
| </li> |
| </ul> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/">Verifications</a> |
| <ul class="nav"> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/text/">Text</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/treetable/">Table/Tree</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/errorlog/">Error Log</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/verifications/time/">Time</a> |
| </li> |
| </ul> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/procedures/">Procedures and Variables</a> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/">Test Runner</a> |
| <ul class="nav"> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/arguments/">Arguments</a> |
| </li> |
| </ul> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/maven/">Maven plugin</a> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/">RAP</a> |
| <ul class="nav"> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/install/">Install instructions</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/recordReplay/">Record and Replay</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/capability/">Capability Contexts</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/rap-commands/">ECL commands</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/rap/rap-maven/">Maven plugin</a> |
| </li> |
| </ul> |
| </li> |
| <li ><a href="https://www.eclipse.org/rcptt/documentation/userguide/integration/">Integration</a> |
| <ul class="nav"> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/integration/test-rail-integration/">TestRail</a> |
| </li> |
| <li > |
| <a href="https://www.eclipse.org/rcptt/documentation/userguide/integration/zephyr-integration/">Zephyr</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <div class="col-sm-9"> |
| <h1>ECL commands for XML import and export</h1> |
| <br> |
| <h2>XML export</h2><hr> |
| |
| <h3>write-xml-file</h3> |
| |
| Writes tables from input pipe to into xml file |
| <br><br> |
| Input: |
| <br> |
| <ul><li><b>tree</b> Tree: Tree to write</li></ul> |
| Parameters: |
| <br> |
| <ul><li><b>uri</b> String: URI to write xml data to. Currently supported schemes are workspace:/ for files in workspace and file:/ for files on local file system.</li></ul> |
| Output: |
| <ul><li> |
| The value of 'tree' argument</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​proc newDevice [val id] [val name] [val target] { |
| tree-node "Device" |
| [map [entry "id" $id]] |
| [tree-node -name "DeviceName" -text $name] |
| [tree-node -name "DeviceTarget" -text $target] |
| } |
| |
| |
| global [val supportedDevices [tree-node "SupportedDevices" |
| [newDevice "1" "device 1" "target 1"] |
| [newDevice "2" "device 2" "target 2"] |
| [newDevice "3" "device 3" "target 3"] |
| ]] |
| |
| global [val allDevices [tree-node "AllDevices" |
| [newDevice "1" "device 1" "target 1"] |
| [newDevice "2" "device 2" "target 2"] |
| [newDevice "3" "device 3" "target 3"] |
| [newDevice "4" "device 4" "target 4"] |
| [newDevice "5" "device 5" "target 5"] |
| ]] |
| |
| global [val tree [ |
| tree-node "DevicesInfo" $supportedDevices $allDevices |
| ]] |
| |
| $tree | write-xml-file "workspace:/xml/devices.xml" |
| </code></pre> |
| |
| |
| <br> |
| <h2>XML import</h2><hr> |
| |
| <h3>read-xml-file</h3> |
| |
| Parses given xml file into tree and write it to output pipe. Fails if file is not found or if it is invalid xml. |
| <br><br> |
| |
| Parameters: |
| <br> |
| <ul><li><b>uri</b> String: URI to read xml data from. Currently supported schemes are workspace:/ for files in workspace and file:/ for files on local file system.</li></ul> |
| <ul><li><b>xPath</b> String: XPath expression to find xml nodes</li></ul> |
| |
| Output: |
| <ul><li> |
| Tree EMF Object</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​ |
| proc logDevice [val device] { |
| if [$device | has-attr "id"] { |
| log [format "Device ID: %s" [$device | get-attr "id"]] |
| } |
| log [format "Device Name: %s" [$device | get-nodes "DeviceName" | get text]] |
| log [format "Device Target: %s" [$device | get-nodes "DeviceTarget" | get text]] |
| } |
| |
| |
| global [val supportedDevices [ |
| read-xml-file "workspace:/xml/devices.xml" |
| | get-nodes "SupportedDevices" | get-nodes "Device" | to-list |
| ]] |
| |
| $supportedDevices | each [val device] { |
| logDevice $device |
| } |
| </code></pre> |
| |
| |
| <br> |
| <h2>Additional commands</h2><hr> |
| |
| <h3>tree-node</h3> |
| |
| Creates a new tree node |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>name</b> String: Name of the new node</li> |
| <li><b>attrs</b> optional EclMap: Map with node attributes</li> |
| <li><b>children</b> (0, ∞) Tree: Children of the new node</li> |
| <li><b>text</b> optional String: Text of the new node</li> |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>Tree EMF Object</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" |
| [map [entry "id" "1"]] |
| [tree-node -name "DeviceName" -text "device"] |
| [tree-node -name "DeviceTarget" -text "target"] |
| </code></pre> |
| |
| |
| <h3>get-attrs</h3> |
| |
| Gets attributes from the object |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to get attributes from</li> |
| |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>Map with object attributes</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" [map [entry "id" "1"] [entry "name" "first"]] |
| | get-attrs | get "name" | log |
| </code></pre> |
| |
| |
| <h3>get-attr</h3> |
| |
| Gets attribute from the tree node by name. Fails if attribute is not found. |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to get attribute from</li> |
| |
| </ul> |
| |
| Parameters: |
| <br> |
| <ul><li><b>name</b> String: Name of the attribute</li></ul> |
| |
| Output: |
| <br><ul> |
| <li>Value of the attribute</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" [map [entry "id" "1"] [entry "name" "first"]] |
| | get-attr "name" | log |
| </code></pre> |
| |
| |
| <h3>set-attr</h3> |
| |
| Sets value of the object attribute. If 'value' parameter is not specified, the attribute will be removed. |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to set attribute to</li> |
| |
| </ul> |
| |
| Parameters: |
| <br> |
| <ul><li><b>name</b> String: Name of the attribute</li> |
| <li><b>value</b> optional String: New value of the attribute</li> |
| |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>The value of 'object' argument</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" [map [entry "id" "1"] [entry "name" "first"]] |
| | set-attr "name" "second" | get-attr "name" | log |
| </code></pre> |
| |
| |
| <h3>has-attr</h3> |
| |
| Checks if the object has attribute<br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to check attribute from</li> |
| |
| </ul> |
| |
| Parameters: |
| <br> |
| <ul><li><b>name</b> String: Name of the attribute</li> |
| |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>true when attribute is exist, false otherwise</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" [map [entry "id" "1"] [entry "name" "first"]] |
| | has-attr "name" | log |
| </code></pre> |
| |
| |
| <h3>get-nodes</h3> |
| |
| Gets child nodes from the object and writes them into output pipe. Fails if 'pos' of 'len' parameter is out of range. |
| |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to get child nodes from</li> |
| |
| </ul> |
| |
| Parameters: |
| <br> |
| <ul> |
| |
| <li><b>name</b> optional String: Name of the nodes</li> |
| <li><b>pos</b> optional Int: Start position. If 'name' attribute is provided, 'pos' is relative to the node list filtered by name.</li> |
| <li><b>len</b> optional Int: Count of nodes. Default value is '-1' and it means the end of the node list. If 'name' attribute is provided, 'len' is relative to the node list filtered by name.</li> |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>Child nodes of the object</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​proc newDevice [val id] [val name] [val target] { |
| tree-node "Device" |
| [map [entry "id" $id]] |
| [tree-node -name "DeviceName" -text $name] |
| [tree-node -name "DeviceTarget" -text $target] |
| } |
| |
| global [val supportedDevices [tree-node "SupportedDevices" |
| [newDevice "1" "device 1" "target 1"] |
| [newDevice "2" "device 2" "target 2"] |
| [newDevice "3" "device 3" "target 3"] |
| ]] |
| |
| $supportedDevices | get-nodes "Device" -pos 1 -len 1 |
| | get-nodes "DeviceName" | get text |
| | equals "device 2" | verify-true |
| </code></pre> |
| |
| |
| <h3>append</h3> |
| |
| Adds child nodes to the object. Fails if 'index' parameter is out of range. |
| |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to add child nodes to</li> |
| |
| </ul> |
| |
| Parameters: |
| <br> |
| <ul> |
| |
| <li><b>children</b> (1, ∞) Tree: New child nodes to add to the object</li> |
| <li><b>index</b> optional Int: Index of the first child node added in the node list. Min value is '0' and max value is size of node list. Default value is '-1' and it means size of node list.</li> |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>The value of 'object' argument</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" [tree-node -name "DeviceName" -text "device"] |
| | append [tree-node -name "DeviceTarget" -text "target"] -index 0 |
| |
| </code></pre> |
| |
| |
| <h3>remove</h3> |
| |
| Removes child node from the object by index. Fails if 'index' parameter is out of range. |
| |
| <br><br> |
| Input: |
| <br><ul> |
| <li><b>object</b> EObject: Object to remove child node from</li> |
| |
| </ul> |
| |
| Parameters: |
| <br> |
| <ul> |
| |
| <li><b>index</b> Int: Index of the child node. Min value is '0' and max value is the last index in the node list. Default value is '-1' and the last index in the node list.</li> |
| </ul> |
| |
| Output: |
| <br><ul> |
| <li>The value of 'object' argument</li></ul> |
| <br> |
| Example: |
| |
| <pre ><code class="language-ecl">​tree-node "Device" |
| [tree-node -name "DeviceName" -text "device"] |
| [tree-node -name "DeviceTarget" -text "target"] |
| | remove -index 1 |
| </code></pre> |
| </div> |
| </div> |
| </div> |
| |
| </section> |
| <script src="https://www.eclipse.org/rcptt/shared/js/main.js"></script> |
| </body> |