XSH XML schema details

The XML schame is rather small and straight forward. Here is a detailed view of the available nodes

To validate a XML file against the XSD schema, you can use xmllint (part of the Gnome XML toolkit)

xmllint --noout --xinclude --schema ${NS_XML}/ns/xsd/xsh/1.0/xsh.xsd ${path-to-your-xml}

Namespace

The schema location is http://xsd.nore.fr/xsh. The namespace prefix xsh is generally used in XML documents.

<xsh:program xmlns:prg="http://xsd.nore.fr/xsh" version="1.0" />

function

Define a UNIX shell function

<xsh:function name="your_func">
    <xsh:parameter name="first_param" />
    <xsh:parameter name="second_param_with_type" type="integer" />
    <xsh:parameter name="third_param_with_default">value</xsh:parameter
    <xsh:body>
    <xsh:local name="func_local_var">inital value</xsh:local>
    <![CDATA[
if [ "${first_param}" ]
then
  echo "$[func_local_var}"
fi
]]></xsh:body>
  </xsh:function>

parameter

Define function parameters (optional)

body

The function body (required)

The <body/> can contain a mix of plain text and <local/> nodes.

local

Function local variable definition. Similar to <parameter/>

program

Define a UNIX shell program

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright © 2011-2012 by Renaud Guillard (dev@nore.fr) -->
<!-- Distributed under the terms of the MIT License, see LICENSE -->
<xsh:program interpreterType="bash" xmlns:prg="http://xsd.nore.fr/program" xmlns:xsh="http://xsd.nore.fr/xsh" xmlns:xi="http://www.w3.org/2001/XInclude">
  <xsh:info>
    <xi:include href="build-shellscript.xml" />
  </xsh:info>
  <xsh:functions>
    <xi:include href="../lib/filesystem/filesystem.xsh" xpointer="xmlns(xsh=http://xsd.nore.fr/xsh) xpointer(//xsh:function[@name = 'ns_realpath'])" />
    <xi:include href="functions.xsh" xpointer="xmlns(xsh=http://xsd.nore.fr/xsh) xpointer(//xsh:function)" />
  </xsh:functions>
  <xsh:code>
    <xi:include href="build-shellscript.body.init.sh" parse="text"/>
    <xi:include href="build-shellscript.body.process.sh" parse="text"/>
  </xsh:code>
</xsh:program>

Attributes

Even if it is not mandatory, it is recommended to specify @interpreterType while specifying @interpreterCommand. The XSLT stylesheets provided in ns-xml attempts to auto-detect it but it may fail when the invocation line is not common and/or complex.

Nodes

info

Program interface definition (optional).

If present, this node must contain a valid <prg:program /> node as described in the Program interface definition schema

functions

A container node for <function />. This node is optional.

If present, it must contain at least one <function />

code

The program code (required). UNIX shell code in plain text.


XML shell file overview