hsk-libs-scripts
270
High Speed Karlsruhe XC878 build scripts
|
This script provides a small command line XML editor. More...
Functions | |
void | filter34 () |
Parse arguments and initialise globals. More... | |
var | empty (var array) |
Return whether an array is empty. More... | |
var | explode (var str, var results) |
Split a string containing attributes into a string array with "attribute=value" entries. More... | |
var | escape (var str) |
Escapes quotation marks and backslashes with backslashes. More... | |
void | cmdSelect (var str) |
This function lets you define a selection. More... | |
void | cmdSearch (var str) |
This function selects any subtree of the current selection that matches the given selection filter. More... | |
void | cmdSet (var value) |
Changes the content of a node. More... | |
void | cmdRename (var name) |
Changes the tag name of a node. More... | |
void | cmdAttrib (var str) |
Changes an attribute of a node. More... | |
void | cmdRenameAttrib (var str) |
Changes the name of an attribute. More... | |
void | cmdInsert (var str) |
Inserts new nodes into all selected nodes, uses the same syntax as cmdSelect() does. More... | |
void | cmdSelectInserted () |
Select the nodes created during the last insert operation. More... | |
void | cmdDelete () |
Unhooks a selected node from the tree, it's still there and can be navigated out of by selecting "..". More... | |
void | cmdDeleteAttrib (var name) |
Deletes a named attribute. More... | |
void | cmdPrint () |
Print the current selection. More... | |
void | printNode (var indent, var node) |
Prints children and contents of the given node. More... | |
void | filter567 () |
Parse the XML tree. More... | |
void | filter631 () |
Execute the specified commands. More... | |
This script provides a small command line XML editor.
It parses the subset of XML used by ARM Keil µVision configuration files and provides arguments to navigate, search, edit and print the parsed XML tree.
Every command applies to the current selection. The current selection may refer to several nodes in the tree.
The command syntax is: "-" command [ ":" argument ]
The following command line arguments are supported:
Command | Function | Description |
---|---|---|
select | cmdSelect() | Selects a path using a filter argument |
search | cmdSearch() | Selects all the subtrees matching the given filter argument |
set | cmdSet() | Sets the data of a node |
rename | cmdRename() | Changes the tag name of a node |
attrib | cmdAttrib() | Sets a named attribute |
renameAttrib | cmdRenameAttrib() | Renames an attribute |
insert | cmdInsert() | Inserts a new child node into the selected nodes |
selectInserted | cmdSelectInserted() | Select all nodes created during the last insert operation |
delete | cmdDelete() | Removes the selected nodes from the tree |
deleteAttrib | cmdDeleteAttrib() | Removes an attribute from the selected nodes |
cmdPrint() | Print the children and data of the selected nodes |
void filter34 | ( | ) |
Parse arguments and initialise globals.
BEGIN
var empty | ( | var | array | ) |
Return whether an array is empty.
array | The array to check |
1 | The array is empty |
0 | The array contains at least one element |
var explode | ( | var | str, |
var | results | ||
) |
Split a string containing attributes into a string array with "attribute=value" entries.
str | The string to split into attributes |
results | The array to store the results in |
var escape | ( | var | str | ) |
Escapes quotation marks and backslashes with backslashes.
str | The string to escape |
void cmdSelect | ( | var | str | ) |
This function lets you define a selection.
A selection filter is a series of node defintions divided by /. Identifiers may contain glob patterns.
A / at the beginning of the filter selects the root node, which contains the root nodes of all XML trees parsed. Other wise the filter is relative to the current selections.
The node ./ refers to the current node and ../ to the parent node. This can be used to move through the tree relative to the current selection or to select the parent of a node that matches a filtering condition.
A node selection has the following syntax: node = tag [ "[" attributes "]" ] [ "=" value ]
Attributes have the following syntax: attributes = attribute "=" ( value | '"' value '"' ) [ " " attributes ]
Values are strings or glob patterns.
str | The selection filter |
void cmdSearch | ( | var | str | ) |
This function selects any subtree of the current selection that matches the given selection filter.
The filter syntax is identical with that of cmdSelect().
str | The selection filter |
void cmdSet | ( | var | value | ) |
Changes the content of a node.
This does not affect subnodes.
value | The value to set the node content to |
void cmdRename | ( | var | name | ) |
Changes the tag name of a node.
name | The new tag name |
void cmdAttrib | ( | var | str | ) |
Changes an attribute of a node.
It accepts a singe string in the shape: attribute "=" value
str | A single attribute definition |
void cmdRenameAttrib | ( | var | str | ) |
Changes the name of an attribute.
If the original attribute does not exist the new one will be added.
If an attribute with the new name already exists it will be overwritten.
It accepts a singe string in the shape: oldname "=" newname
str | A single attribute renaming instruction |
void cmdInsert | ( | var | str | ) |
Inserts new nodes into all selected nodes, uses the same syntax as cmdSelect() does.
str | A node definition like the ones used for selection filters |
void cmdSelectInserted | ( | ) |
Select the nodes created during the last insert operation.
void cmdDelete | ( | ) |
Unhooks a selected node from the tree, it's still there and can be navigated out of by selecting "..".
void cmdDeleteAttrib | ( | var | name | ) |
Deletes a named attribute.
name | The name of the attribute to remove |
void cmdPrint | ( | ) |
Print the current selection.
void printNode | ( | var | indent, |
var | node | ||
) |
Prints children and contents of the given node.
indent | The indention depth of the current node |
node | The node to print |
void filter567 | ( | ) |
Parse the XML tree.
Abbreviations:
Properties:
void filter631 | ( | ) |
Execute the specified commands.
END