To make the example as short and as clear as possible, I don’t use the default LT grammar rules in this example. (You can use the default rules and your external rules at the same time.)
Grammar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rules [
<!ENTITY MyRules SYSTEM "file:///D:/data-files/grammar-test.xml">
<!ENTITY apostrophe "['’`´‘]">
]>
<rules lang="en" xsi:noNamespaceSchemaLocation="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/rules.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
&MyRules;
</rules>
The rules in grammar-text.xml:
<category id="MY_EXTERNAL_RULES" name="Rules in grammar-test.xml" type="style" external="yes">
<rule id="CAT_FELINE" name="cat (feline)">
<pattern>
<token>cat</token>
</pattern>
<message>Don't use simple words. Did you mean 'feline'?</message>
<short>grammar-test: feline</short>
<example type="incorrect">The <marker>cat</marker> sat on the mat.</example>
<example>The <marker>feline</marker> sat on the mat.</example>
</rule>
</category>