Note that the X-definition in the example below has the attributes "name" and "root" (see line 1). The "root" attribute specifies which model represents the root element of the input data. The "name" attribute is required as a reference name pointing to the X-definition in the collection of the X-definition set.
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Example" root="Inventory" > <xd:declaration> void message(String s) { outln(s); } int count = 0; </xd:declaration> <Inventory xd:script="init message('Created ' + now()); finally message('Processed ' + count + ' books');"> <Book xd:script="occurs +; onAbsence error('No books!'); finally {count++; outln('ISBN code: " ' + @ISBN)};" ISBN="int(10000000, 999999999);" published="optional gYear();" > <Author xd:script="occurs *" > string() </Author> <Title> string(); </Title> </Book> </Inventory> </xd:def>You can try it HERE