VoiceXML 2.1 Development GuideHome  |  Frameset Home


<ruleref>  element

The ruleref element is an SRGS addition to VXML 2.0 that allows the developer to specify an existing rule for inclusion within the current grammar.


usage
<ruleref special="(NULL|VOID|GARBAGE)" uri="CDATA">


attributes
specialData Type: (NULL|VOID|GARBAGE)Default: Optional
The special attribute denotes rulenames which are disallowed for redefinition within a grammar. Allowable values are:

  • NULL -- A rule which is automatically matched
  • VOID --  A rule that can never be spoken
  • GARBAGE -- A rule that may match any speech up until the next rule match

Note that either special or uri may be defined for the Ruleref element, but not both. Also be aware that while these special ruleref classes are not accessible when using the Prophecy ASR, they can be used when using Prophecy with the Nuance ASR.
uriData Type: CDATADefault: Optional
The uri attribute specifies the URI of the external grammar that is to be referenced. Note that existing rules within the same file can be referenced:

<ruleref uri="#MYRULE"/>

or rules from an external file may be referenced:

<ruleref uri="MyGrammar.xml#MYRULE"



shadow variables
none


parents
<item> <rule>


children
none


code samples
<RuleRef URI> sample
<?xml version="1.0" encoding="UTF-8" ?>


<vxml version = "2.1">

<meta name="author" content="Matthew Henry"/>
<meta name="copyright" content="2005 voxeo corporation"/>
<meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/>

<form id="F1">

  <field name="F_1">
    <prompt>
      William Burroughs. Is he just an understated genius,
or simply a half baked junkie writer?
    </prompt>

    <grammar src="MyGram.xml" type="application/grammar-xml"/>

    <filled>
      <prompt>
        Say, that guess is as good as any, I suppose.
    </prompt>

  </filled>

  </field>

</form>

</vxml>

<MyGram.xml>
<?xml version= "1.0"?>


<grammar xmlns="http://www.w3.org/2001/06/grammar"
        xml:lang="en-US"
        root="MYRULE">

  <rule id="MYRULE">
      <one-of>
        <item>

        <!-- note that a fully qualified URL is required -->
<ruleref uri=
            "http://MyServer.com/MyDirectory/MyAlias.xml#MYRULE3"/>

        </item>
        <item> alien <tag> <![CDATA[  <F_1 "alien"> ]]>  </tag> </item>
      </one-of>
    </rule>

</grammar>

Motorola <MyAlias.xml>
<?xml version= "1.0"?>

<grammar xmlns="http://www.w3.org/2001/06/grammar"
          xml:lang="en-US"
          root="MYRULE3">

<!-- note that we MUST declare the rule scope as 'public' -->         
  <rule id="MYRULE3" scope="public">
    <one-of>
      <item> genius <tag> <![CDATA[  <F_1 "genius"> ]]>  </tag> </item>
      <item> smart <tag> <![CDATA[  <F_1 "smart"> ]]>  </tag> </item>
      <item> dumb <tag> <![CDATA[  <F_1 "dumb"> ]]>  </tag> </item>     
    </one-of>
  </rule>
</grammar>



additional links
W3C SRGS 1.0 Specification


  ANNOTATIONS: EXISTING POSTS
mtatum111
9/15/2008 12:26 PM (EDT)
<rule name = "Fairy_tale_character">
    <item> <ruleref special = "GARBAGE"/>Red Ridinghood</item>
</rule>

Can you explain the above to me.  I don't quite understand what "GARBAGE" does.

Thanks in Advance.
MattHenry
9/15/2008 12:39 PM (EDT)

Hello Melissa,


I think I can help explain this so that you have a better understanding as to how this works. The first thing that I should make clear is that these "special" rulerefs can only be used when using the Prophecy platform with the Nuance ASR: The Prophecy ASR has no native support for these settings in any capacity.

The second thing I wanted to do was to show you a real-world example of this in action to give you some context:

<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="INTRO">



<!-- ********** -->


<rule id="INTRO">

<one-of>
    <item>

      <one-of> 
        <item>
    repeat     
        </item>
      </one-of>
<tag> <![CDATA[  <MySlot "repeat">  ]]>  </tag>
        <item repeat="0-1">
  please
</item>

  <item repeat="0-1">
    <ruleref special="GARBAGE"/> 
  </item>

  </item>
</one-of>

    </rule>
</grammar>

What ruleref=GARBAGE does is to allow a caller to mumble any utterance, usually as a prefix or suffix to the "real" utterance that we want to capture and not have these additional utterances impact a valid match: I'm hard pressed to think of a scenario where GARBAGE would come in handy by itself without waxing really creative.

To further this explanation, take a look at the above grammar, especially the careful nesting of the one-of and item elements. You'll note that the second set of item elements specify a repeat value of 0-1, which makes them optional suffix utterances. As this is the case, then any of the following user utterances would be considered a valid match:


- "repeat"
- "repeat please"
- "repeat with a half a loaf of rye bread and a side of squid ink"


Hope this helps to better explain,

~Matthew Henry
mtatum111
9/15/2008 3:56 PM (EDT)
Matthew, thanks for the explanation.  To go a step further,
can you explain special="VOID" and special="NULL"

Not quite sure that I understand these.

Thanks for any clarification.
VoxeoDustin
9/15/2008 4:24 PM (EDT)
Hey Melissa,

Per the W3C spec:

NULL
    Defines a rule that is automatically matched: that is, matched without the user speaking any word.

    XML Form: <ruleref special="NULL"/>
VOID
    Defines a rule that can never be spoken. Inserting VOID into a sequence automatically makes that sequence unspeakable.

    XML Form: <ruleref special="VOID"/>

http://www.w3.org/TR/speech-grammar/#S2.2.3

Let me know if you have any further questions.

Thanks,
Dustin
mtatum111
9/15/2008 9:28 PM (EDT)
Can you explain why you would use <ruleref> as a child of item vs. a child of <rule> 
I am just trying to understand the differences depending on what the parent is (in this case item or rule).

Thanks for any clarification.
voxeoJeffK
9/16/2008 3:00 AM (EDT)
Hi,

<ruleref> is just an expansion. It just points to another <rule>. If your <ruleref> is a child of <item> then you do have use of <item>'s "repeat" and "weight" attributes, but basically it depends on how you have structured your <rule>s.

<!--item as parent-->
  <rule id="request" scope="public">
    may I speak with
    <one-of>
      <item> <ruleref uri="#peopleInAccounting"/> </item>
      <item> <ruleref uri="#peopleInEngineering"/> </item>
    </one-of>
  </rule>

<!-rule as parent-->
<rule id="mailing">
  <!--return the box...or...send the envelope-->
  <ruleref uri="#mailActions"/>
  <ruleref uri="#mailObjects"/>
</rule>

hope that helps,
Jeff K.

login



© 2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site