I have some trouble figuring out how to write grammar rules inline directly in scxml files instead of linking to them in an external grxml files.
Let me illustrate it on an example:
combat.scxml
------------
<?xml version="1.0" encoding="utf-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:vxml="http://www.w3.org/2001/vxml" version="1.0" initial="Start">
<state id="WeaponChoice">
<onentry>
<vxml:prompt>What kind of weapon do you want to use?</vxml:prompt>
</onentry>
<datamodel>
<data id="WeaponChoiceGrammar" expr="./combat.grxml#weapon"/>
</datamodel>
</state>
</scxml>
combat.grxml
------------
<?xml version="1.0" encoding="utf-8"?>
<grammar>
<rule id="weapon">
<one-of>
<item>sword</item>
<item>knife</item>
<item>hammer</item>
<item>bow</item>
<item>crossbow</item>
</one-of>
</rule>
</grammar>
If I wanted to write that grammar rule inline in the <data> element in combat.scxml, I would do it like this:
combat.scxml
------------
<?xml version="1.0" encoding="utf-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:vxml="http://www.w3.org/2001/vxml" version="1.0" initial="Start">
<state id="WeaponChoice">
<onentry>
<vxml:prompt>What kind of weapon do you want to use?</vxml:prompt>
</onentry>
<datamodel>
<data id="WeaponChoiceGrammar">
<rule id="weapon">
<one-of>
<item>sword</item>
<item>knife</item>
<item>hammer</item>
<item>bow</item>
<item>crossbow</item>
</one-of>
</rule>
</data>
</datamodel>
</state>
</scxml>
Now, let's suppose combat.grxml is like this:
combat.grxml
------------
<?xml version="1.0" encoding="utf-8"?>
<grammar>
<rule id="weapon">
<one-of>
<item tag="melee"><ruleref uri="#melee"/></item>
<item tag="ranged"><ruleref uri="#ranged"/></item>
</one-of>
</rule>
<rule id="melee">
<one-of>
<item>sword</item>
<item>knife</item>
<item>hammer</item>
</one-of>
</rule>
<rule id="ranged">
<one-of>
<item>bow</item>
<item>crossbow</item>
</one-of>
</rule>
</grammar>
Now, how could I write that inline in the <data> element in combat.scxml, like I did in the previous case?