Discussion:
How to refer to an external grammar file w/ruleref URL
(too old to reply)
cjreynolds
2009-03-24 22:50:10 UTC
Permalink
I have a grammar (xml) file, and one of the top-level rules is:

<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some</P>
<RULEREF NAME="ArtList"/>
</RULE>

Then in the same file I have:

<RULE NAME="ArtList">
<L>
<P>AC-DC</P>
<P>Aerosmith</P>
<P>Al Di Meola</P>
<P>Allman Brothers</P>
<P>Alvin Lee</P>
etc...
</L>
</RULE>

I would like to have the "ArtList" in a separate file (ie: artlist.xml).

I've tried

<!--#include FILE="artlist.xml" -->

Didn't work - tried putting a URL property in the ruleref tag:

<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some</P>
<RULEREF NAME="ArtList" URL="artlist.xml"/>
</RULE>

but that didn't work either. Tried absolute pathname in the URL
(URL="file://f:/tmp/artlist.xml"/) but that failed.

What am I missing here?
Philip Youssef [MSFT]
2009-03-31 21:12:14 UTC
Permalink
Hey CJ,

Instead of <RULEREF NAME="ArtList" URL="artlist.xml"/>
try
<RULEREF NAME="ArtList" URI="artlist.xml"/>
(replace url with uri)

below is a w3c grammar that has external file references:
------------------------
seasons.xml:
<grammar xml:lang="en" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar" root="seasons">
<rule id="seasons">
<item repeat="0-1"><ruleref uri="modifier.xml"/></item>
<one-of>
<item>Autumn</item>
<item>Summer</item>
<item>Winter</item>
<item>Spring</item>
</one-of>
</rule>
</grammar>
-----------------------
modifier.xml:
<grammar xml:lang="en" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar" root="modifier">
<rule id="modifier">
<item>beautiful</item>
</rule>
</grammar>
----------------------

Hope this helps,
Philip
Post by cjreynolds
<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some</P>
<RULEREF NAME="ArtList"/>
</RULE>
<RULE NAME="ArtList">
<L>
<P>AC-DC</P>
<P>Aerosmith</P>
<P>Al Di Meola</P>
<P>Allman Brothers</P>
<P>Alvin Lee</P>
etc...
</L>
</RULE>
I would like to have the "ArtList" in a separate file (ie: artlist.xml).
I've tried
<!--#include FILE="artlist.xml" -->
<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some</P>
<RULEREF NAME="ArtList" URL="artlist.xml"/>
</RULE>
but that didn't work either. Tried absolute pathname in the URL
(URL="file://f:/tmp/artlist.xml"/) but that failed.
What am I missing here?
cjreynolds
2009-04-02 15:39:02 UTC
Permalink
Already ahead - tried <RULEREF NAME="ArtList" URI="artlist.xml"/>

tried <RULEREF URI="artlist.xml#ArtList"/>

even tried leaving the ArtList rule in the same file and using <RULEREF
URI="#ArtList"/>, which EVERYONE says should work, but it don't work for me.

I'm beginning to think the structure of my grammar files might be at fault.
Here is a condensed version of my main grammar file:

<GRAMMAR LANGID="409">

<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some ?More</P>
<RULEREF NAME="ArtList" />
</RULE>

</GRAMMAR>

Does the header, etc. look OK to you?

When I try
<grammar xml:lang="en" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar" root="modifier">

instead of <GRAMMAR LANGID="409">, I get the same error, even without the
ruleref URI property.
Post by Philip Youssef [MSFT]
Hey CJ,
Instead of <RULEREF NAME="ArtList" URL="artlist.xml"/>
try
<RULEREF NAME="ArtList" URI="artlist.xml"/>
(replace url with uri)
------------------------
<grammar xml:lang="en" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar" root="seasons">
<rule id="seasons">
<item repeat="0-1"><ruleref uri="modifier.xml"/></item>
<one-of>
<item>Autumn</item>
<item>Summer</item>
<item>Winter</item>
<item>Spring</item>
</one-of>
</rule>
</grammar>
-----------------------
<grammar xml:lang="en" version="1.0"
xmlns="http://www.w3.org/2001/06/grammar" root="modifier">
<rule id="modifier">
<item>beautiful</item>
</rule>
</grammar>
----------------------
Hope this helps,
Philip
Post by cjreynolds
<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some</P>
<RULEREF NAME="ArtList"/>
</RULE>
<RULE NAME="ArtList">
<L>
<P>AC-DC</P>
<P>Aerosmith</P>
<P>Al Di Meola</P>
<P>Allman Brothers</P>
<P>Alvin Lee</P>
etc...
</L>
</RULE>
I would like to have the "ArtList" in a separate file (ie: artlist.xml).
I've tried
<!--#include FILE="artlist.xml" -->
<RULE NAME="dosome" TOPLEVEL="ACTIVE">
<P>Merlin Do Some</P>
<RULEREF NAME="ArtList" URL="artlist.xml"/>
</RULE>
but that didn't work either. Tried absolute pathname in the URL
(URL="file://f:/tmp/artlist.xml"/) but that failed.
What am I missing here?
Loading...