Re: All teidata.pointer attributes
Syd Bauman <[email protected]>
| Newsgroups | gmane.text.tei.general |
|---|---|
| Message-ID | <[email protected]> |
John --
Sorry it has taken so long for me to get to posting this. Was off at
the TEI Council meeting, a one day TEI conference, and a 3-day XML
conference.
Lou is indeed correct, to do this properly you need to chase class
references. (Because not only might a pointer attribute be a member
of a class, that class might be a member of a class.) You can do it
using any of the following as the base from which you figure out
which element & attribute pairs are pointers.
* Your customization ODD -- very hard, as you have to
"compile" the ODD by merging it with the P5 ODD first;
* Your compiled ODD; or
* Your RELAX NG schema.
No matter which base you choose, with XSLT 1 or XSLT 2 you have to
use a 2-step process. (I think you can do it in 1 step in XSLT 3, but
I'm not sure as I've never tried. :-)
Step 1 reads in the compiled ODD or the RELAX NG schema and writes
out an XSLT stylesheet. Step 2 runs that XSLT stylesheet using your
document instance as input. The output is (hopefully) exactly what
you want: a copy of that document instance decorated with attributes
that say "this element has a pointer attribute".
I have written sample implementations of step 1 for both of those
inputs. You can find them at
http://paramedic.wwp.neu.edu/~syd/temp/TEI/JPM_generate_ptr_attr_flagger_from_ODD.xslt
and
http://paramedic.wwp.neu.edu/~syd/temp/TEI/JPM_generate_ptr_attr_flagger_from_RNG.xslt
IIRC Lou has already explained how to get your hands on the RNG;[1]
and generating the compiled ODD can be a bit tricky, so I suspect
you're going to prefer the latter.[2] But Peter insisted I write the
former, too, as it is somewhat more appropriate and cleaner. (The RNG
version, e.g., relies on the fact that TEI attribute class names
start with "att.". So it's somewhat more fragile. On the other hand,
I don't think anyone wants to change that naming convention. :-)
Caveats:
* I have not tested these carefully
* These are not necessarily the "right" or "best" way to do this,
nor particularly good examples of XSLT.[3]
If someone has a better way to do this, or can suggest improvements
to my XSLT, I'm all ears. If there is community interest I could
spiff these up a bit and put them up on the TEI wiki.
Anyway, there are a variety of ways of combining those two steps into
one, the most obvious of which is to use XProc. (But one could also
use a shell script, ant, or make.)
Notes
-----
[1] Given that you use oXygen, run the "TEI ODD to RelaxNG XML"
transformation scenario using your customization ODD as the input
document. (If you don't see the various ODD transformations when
you click "Configure Transformation Scenario(s)" (cmd-shift-C or
ctl-shift-C), remember to choose "Show all scenarios" from the
little blue gear in the upper right corner of the dialog box.) At
the moment the output is put into a directory called out/ that is
in the same directory as the input.
[2] Furthermore, I've just discovered a minor problem with use of the
compiled ODD, which some may consider a bug. The declarations for
at least some elements that are never used are still in the ODD.
(E.g., the specification of the <typeNote> element is still in
the compiled "tei_drama.odd.odd" file, even though there is no
<typeDesc> element, so <typeNote> can never occur.) They have
been removed by the time you get to the RELAX NG. Worth noting
that these won't change your output -- you just end up trying to
match an element/attribute combination (e.g.,
typeNote/@scribeRef) that can never be there. Oh well, there's
another 18 microseconds of your life you will never get back. :-)
[3] E.g., I suspect that in the RNG version, the template that
matches "data" in "class" mode and the template named
"chase-attr-class" could be combined into a single more readable
template. And in that "data" mode "class" template it might be
clearer to test for something to return by checking count($all)
rather than the length of the joined string.