Back to LanguageTool Homepage - Privacy - Imprint

Tip for Rule Developers to avoid copy and paste


(Fabian Richter) #1

I just found a neat trick to avoid duplicating code in XML:
Entities (as already defined at the top of most grammar.xml files) can also contain XML code, like this:

<!ENTITY date_numbers_pattern '
    <pattern>
           <token regexp="yes">\d\d?</token>
            <token>.</token>
            <token regexp="yes">\d\d?</token>
            <token>.</token>
            <token regexp="yes">\d\d\d\d</token>
    </pattern>
'>

You would then use this later like this:
&date_numbers_pattern