Quick Reference
Use this chapter as a day-to-day lookup while writing iXML. It covers all namespaces with brief syntax reminders and links to the full documentation.
Variables and Expressions
| Task | Pattern |
|---|---|
| Set variable | <set var="name">value</set> |
| Set with key | <set var="name" key="k">value</set> |
| Unset variable | <unset var="name"/> |
| Substitute variable | $name |
| Key chain access | $name.key or $name[0] |
| Arithmetic | $(3 + 2) |
| Inline function call | $fn(arg) |
| Cast type | <cast var="name" type="int"/> |
| Check type | <typeof var="name" var_result="t"/> |
| Check class | <instanceof var="obj" class="MyClass" var_result="r"/> |
| String length | <length var="len">$str</length> |
| Array/string size | <size var="s">$arr</size> |
| Assign by reference | <assign var="a" var_source="b"/> |
| Clone variable | <clone var="copy" var_source="original"/> |
| Swap variables | <swap var="a" var_source="b"/> |
| Evaluate expression | <eval var="result">$expr</eval> |
| Global variable | <global var="name"/> |
| Literal dollar sign | $$ |
| No substitution | <verbatim>$not_substituted</verbatim> |
String Operations
| Task | Pattern |
|---|---|
| Lowercase | <tolower var="result">$str</tolower> |
| Uppercase | <toupper var="result">$str</toupper> |
| Trim | <trim var="result">$str</trim> |
| Substring | <substr var="result" from="0" length="5">$str</substr> |
| Find position | <pos var="result" find="needle">$str</pos> |
| Replace | <replace var="result" find="old" replace="new">$str</replace> |
| Regex replace | <replace var="result" find="/pattern/" replace="new" type="regex">$str</replace> |
| Split | <split var="result" delimiter=",">$str</split> |
| Pad | <pad var="result" length="10" padding="0" type="left">$str</pad> |
| Concat | <concat var="result" glue=", " var_result="out"/> |
| Match regex | <match var="result" pattern="/regex/">$str</match> |
| Char code to char | <char var="result">65</char> |
| Char to code | <ord var="result">A</ord> |
Control Flow
| Task | Pattern |
|---|---|
| If equals | <if value1="$a" value2="$b">...</if> |
| If with operator | <if value1="$a" func=">" value2="$b">...</if> |
| If regex | <if value1="$a" func="~" value2="/pattern/">...</if> |
| If/else | <if ...>...<else>...</else></if> |
| Type check | <is var="x" type="array">...</is> |
| Switch | <switch value="$x"><case value="1">...</case><default>...</default></switch> |
| For loop | <for var="i" from="1" to="10">...</for> |
| Foreach | <foreach var="arr" var_key="k" var_value="v">...</foreach> |
| While loop | <while value1="$i" func="<" value2="10">...</while> |
| Break loop | <break/> |
| Next iteration | <next/> |
| Exit execution | <exit/> |
| Return value | <return>value</return> |
Comparison Operators (func attribute)
| Operator | Description |
|---|---|
= | Equals |
!= | Not equals |
< | Less than |
<= | Less than or equal |
> | Greater than |
>= | Greater than or equal |
=* | Case-insensitive equals |
!=* | Case-insensitive not equals |
_ | Contains |
!_ | Does not contain |
^ | Starts with |
!^ | Does not start with |
$ | Ends with |
!$ | Does not end with |
~ | Regex match |
!~ | Regex does not match |
~~ | LIKE pattern |
!~~ | NOT LIKE pattern |
Functions, Classes, and Modules
| Task | Pattern |
|---|---|
| Define function | <function var="fn">...</function> |
| Call function | <call func="fn" var="result"/> |
| Define macro | <macro var="m">...</macro> |
| Expand macro | <expand macro="m"/> |
| Define class | <class var="C"><property>...<method>...</class> |
| Instantiate | <new class="C" var="obj"/> |
| Include resource | <include id="resource_id" type="resource"/> |
| Pass parameter | <param var="name"/> |
Error Handling
| Task | Pattern |
|---|---|
| Try/catch | <try>...<catch var="err">...</catch></try> |
| Try/else (success) | <try>...<else>...</else></try> |
| Try/finally | <try>...<finally>...</finally></try> |
| Raise error | <error>message</error> |
| Raise warning | <warning>message</warning> |
Array Operations
| Task | Pattern |
|---|---|
| Create array | <array var="arr"><item key="k">v</item></array> |
| Push item | <array:push var="arr">value</array:push> |
| Pop item | <array:pop var="arr" var_result="val"/> |
| Shift item | <array:shift var="arr" var_result="val"/> |
| Unshift item | <array:unshift var="arr">value</array:unshift> |
| Sort | <array:sort var="arr"/> |
| Reverse | <array:reverse var="arr"/> |
| Merge | <array:merge var="a" var_source="b"/> |
| Slice | <array:slice var="arr" var_result="sub" offset="0" length="5"/> |
| Splice | <array:splice var="arr" offset="2" length="1"/> |
| Search | <array:search var="arr" var_result="key">value</array:search> |
| Key exists | <array:keyexists var="arr" var_result="r" key="k"/> |
| Keys | <array:keys var="arr" var_result="keys"/> |
| Values | <array:values var="arr" var_result="vals"/> |
| Join | <array:join var="arr" var_result="str" glue=","/> |
| Unique | <array:unique var="arr"/> |
| Filter | <array:filter var="arr"/> |
| Map | <array:map var="arr" func="fn"/> |
| Walk | <array:walk var="arr" func="fn"/> |
| Chunk | <array:chunk var="arr" var_result="chunks" size="3"/> |
| Column | <array:column var="arr" var_result="col" key="name"/> |
| Combine | <array:combine var_keys="k" var_values="v" var_result="arr"/> |
Database
| Task | Pattern |
|---|---|
| Get entity | <db:get var="obj" entity="contacts" id="$id"/> |
| Set entity | <db:set entity="contacts" id="$id" var_data="obj"/> |
| Remove entity | <db:remove entity="contacts" id="$id"/> |
| Lookup entity | <db:lookup var="id" entity="contacts" field="email">$email</db:lookup> |
| Select rows | <db:select var="rows" entity="contacts" type="assoc" limit="10">...</db:select> |
| Insert row | <db:insert entity="contacts"><db:value field="name">Ada</db:value></db:insert> |
| Update rows | <db:update entity="contacts"><db:value field="name">New</db:value><db:is ...>...</db:update> |
| Delete rows | <db:delete entity="contacts"><db:is ...>...</db:delete> |
| Raw SQL | <db:run var="result" type="assoc">SELECT ...</db:run> |
| Transaction | <db:transaction>...</db:transaction> |
| NULL check | <db:isnull field="c.email"/> |
| NOT NULL check | <db:isnotnull field="c.email"/> |
| IN list | <db:in var="list" field="c.type"/> |
| Full-text search | <db:search query="term"><db:searchfield field="c.name"/></db:search> |
Result types: num (default), assoc, list, av, single, self, value
REST and HTTP
| Task | Pattern |
|---|---|
| REST server | <rest:server>...</rest:server> |
| REST resource | <rest:resource route="/items/:id" method="GET" var_body="body">...</rest:resource> |
| HTTP request | <http:request var="resp" url="..." method="GET"/> |
| URL parse | <http:url var="parts">$url</http:url> |
| Query string | <http:query var="params"/> |
| Set HTTP status | <set var="return">404</set> |
| Set header | <header>Content-Type: application/json</header> |
Encoding / Decoding
| Format | Encode | Decode |
|---|---|---|
| JSON | <encode:json var="x" var_result="raw" pretty="1"/> | <decode:json var="x">$raw</decode:json> |
| XML entities | <encode:xml var="safe">$text</encode:xml> | <decode:xml var="plain">$safe</decode:xml> |
| CSV | <encode:csv var="rows" var_result="csv" delimiter=";"/> | <decode:csv var="rows" delimiter=";">$csv</decode:csv> |
| Base64 | <encode:base64 var="enc">$data</encode:base64> | <decode:base64 var="dec">$enc</decode:base64> |
| URL | <encode:url var="enc">$val</encode:url> | <decode:url var="dec">$enc</decode:url> |
| Hash | <encode:hash var="h" algorithm="sha256">$data</encode:hash> | — |
| HMAC | <encode:hash var="h" algorithm="sha256" key="secret">$data</encode:hash> | — |
| AES encrypt | <encode:aes var="enc" key="..." iv="...">$data</encode:aes> | <decode:aes var="dec" key="..." iv="...">$enc</decode:aes> |
| Compress | <encode:deflate var="compressed">$data</encode:deflate> | <decode:inflate var="decompressed">$data</decode:inflate> |
PDF
| Task | Pattern |
|---|---|
| Create document | <pdf:document var="pdf" title="...">...</pdf:document> |
| Add section | <pdf:section format="A4" orientation="P">...</pdf:section> |
| Header/footer/body | <pdf:header>...</pdf:header> |
| Style text | <pdf:style fontsize="10" fontstyle="B">...</pdf:style> |
| Block text | <pdf:block>text</pdf:block> |
| Inline text | <pdf:inline>text</pdf:inline> |
| Table row | <pdf:row><pdf:col width="50">text</pdf:col></pdf:row> |
| Image | <pdf:image filename="path" width="40"/> |
| Barcode | <pdf:barcode type="QRCODE,M" width="30">data</pdf:barcode> |
| Line break | <pdf:linebreak offset="5"/> |
| Page break | <pdf:pagebreak/> |
| Get position | <pdf:getpos var_page="p" var_y="y"/> |
| Set position | <pdf:setpos y="100"/> |
Excel
| Task | Pattern |
|---|---|
| Create workbook | <excel:workbook>...</excel:workbook> |
| Set cell | <excel:set coords="A1" type="numeric">42</excel:set> |
| Get cell | <excel:get var="val" coords="A1"/> |
| Move cursor | <excel:setpos sheet="0" row="5" col="0"/> |
| Add sheet | <excel:addsheet>Title</excel:addsheet> |
| Apply style | <excel:style var="styleArray">A1:B5</excel:style> |
| Auto-filter | <excel:autofilter>A1:D100</excel:autofilter> |
| Export to array | <excel:array var="data"/> |
| Generate file | <excel:create var="book" format="xlsx"/> |
File Operations
| Task | Pattern |
|---|---|
| Read file | <file:read var="content" filename="path"/> |
| Write file | <file:write filename="path">content</file:write> |
| Append | <file:append filename="path">content</file:append> |
| Read CSV | <file:readcsv var="rows" filename="path" delimiter=","/> |
| Read JSON | <file:readjson var="data" filename="path"/> |
| Write CSV | <file:writecsv var="rows" filename="path" delimiter=","/> |
| Write JSON | <file:writejson var="data" filename="path"/> |
| File exists | <file:exists var="e" filename="path"/> |
| File type | <file:typeof var="t" filename="path"/> |
| Path info | <file:pathinfo var="info" filename="path"/> |
| List directory | <file:listdir var="files" dirname="path"/> |
| Glob | <file:glob var="files" pattern="*.csv"/> |
| Delete | <file:delete filename="path"/> |
| Make directory | <file:makedir dirname="path"/> |
ZIP
| Task | Pattern |
|---|---|
| Open archive | <zip:archive filename="path">...</zip:archive> |
| Write entry | <zip:write filename="entry">content</zip:write> |
| Read entry | <zip:read var="data" filename="entry"/> |
| List entries | <zip:list var="entries"/> |
| Check entry | <zip:exists var="found" filename="entry"/> |
| Delete entry | <zip:delete filename="entry"/> |
ZeyOS Platform
| Task | Pattern |
|---|---|
| Get custom fields | <extdata:get var="data" entity="contacts" id="$id"/> |
| Set custom fields | <extdata:set entity="contacts" id="$id" var_data="data"/> |
| List tags | <tags:list var="tags" entity="contacts" id="$id"/> |
| Add tags | <tags:add entity="contacts" id="$id"><tags:name>VIP</tags:name></tags:add> |
| Store temp data | <temp:write var="id">content</temp:write> |
| Read temp data | <temp:read var="content" id="$id"/> |
| Get temp path | <temp:path var="path" id="$id"/> |
| Store binary | <bin:write var="id">data</bin:write> |
| Next number | <numformat:next var="num" name="sequence"/> |
| Authenticate | <auth:simple var="user" username="..." password="..."/> |
| Get session | <session var="session"/> |
| Get config | <config var="config"/> |
| Run Zymba | <zymba:run var="result"><zymba:code>...</zymba:code></zymba:run> |
Common Pitfalls
| Pitfall | Correct Approach |
|---|---|
<if condition="..."> | Use value1, value2, func attributes |
<set var="$name"> | Remove $ — it is substitution syntax only |
func="<" in attribute | Escape as func="<" |
<set var="x">42</set> is integer | It's a string — use <cast var="x" type="int"/> |
<db:is field="x">NULL</db:is> | Use <db:isnull field="x"/> |
<db:isnot ...> | Does not exist — use <db:is func="!="> |
<encode:hmac> | Does not exist — use <encode:hash key="secret"> |
<array:count> | Does not exist — use <size var="n">$arr</size> |
<decode:json> without var | Always use var to capture the parsed result |
| CSV delimiter assumed comma | Default is ; — specify delimiter="," explicitly |