Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.47 ruleref

Element type



special | tag | uri | xml:lang


item | rule




Allows a rule expansion to refer to an existing rule element as part of its definition. This element allows for the development of reusable rules.


<!ELEMENT ruleref (tag) >
<!ATTLIST ruleref
  uri      CDATA   #IMPLIED
  special  CDATA   #IMPLIED
  tag      CDATA   #IMPLIED >

Language model


  • special : CDATA

    Indicates that this rule reference points to a “built-in,” rule. The special rules currently supported are #NULL, #VOID, and #GARBAGE.

  • tag : CDATA

    Specifies the action to be taken if this rule reference participates in the matching of its containing rule element. This action is typically written as an ECMAScript expression.

  • uri : CDATA

    The URI of the rule being referred to. It must point to an existing rule either within the same document or in another document. The former would be represented with a URI of the form #ruleid where ruleid is equal to the desired rule element's id attribute value. The latter would be represented with a URI of the form uri#ruleid where uri points to a document containing the desired rule and ruleid is as described above.

  • xml:lang : NMTOKEN

    Specifies the spoken language used with this element - for example, en-US for US English.




The rulerefs in Example 3-58 call the city rule which is defined elsewhere. If this item element is matched, the ECMAScript interpreter will execute each of the ruleref elements' tag attributes.

Example 3-58 A ruleref element referring to the city rule

<?xml version="1.0" encoding="iso-8859-1"?>
<vxml version="2.0">
    <grammar root="flightrule">
      <rule id="flightrule" scope="public">
        <count number="optional">
          <item>I'd like to fly</item>
        to <ruleref uri="flightGrammars.grxml#city"> 
        from <ruleref uri="flightGrammars.grxml#city"> 
    <initial>Say where you are flying to and from.</initial>
    <field name="arrive"/>
    <field name="depart"/>
        Got it. You're flying from <value expr="depart"/>
        to <value expr="arrive"/>.
  • + Share This
  • 🔖 Save To Your Account