[macker-user] Including external files
Brought to you by:
barredijkstra,
melquiades
From: Paul C. <can...@po...> - 2005-05-11 19:14:18
|
A Macker user wrote in to ask if there's a way to include shared pattern definitions between rules files. (Hi Michael!) There is, though it's a bit ugly: use XML external entities. Create a file -- say "my-patterns.xml" -- next to your rules file. Put your shared patterns / rules / whatever in it: <var name="basepkg" value="net.innig.macker" /> <pattern name="macker" class="${basepkg}.**" /> ..etc.. Then change your rules file so that it starts like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE macker PUBLIC "-//innig//DTD Macker 0.2//EN" "http://innig.net/macker/dtd/macker-0.4.dtd" [ <!ENTITY myPatterns SYSTEM "my-patterns.xml"> <!-- you can add more entity declarations here --> ]> <macker> ...etc... Finally, at the point in your rules file where you want to include the shared patterns, do this: &myPatterns; This plops my-patterns.xml straight into your document at that location, sort of like an #include in C. Not pretty, but it does work. I'm open to suggestions for a simple include facility to replace this. Paul _________________________________________________________________ "Prediction is hard, especially of the future." -- Niels Bohr |