4

Is there a way extend xindy in a way that it passes some meta information through the sorting algorithm and then to process those information in the output markup?

Specificly, i need my index terms to not only show the page number but also an section id and the volume of the book it occcurs in. Is there a way to pass those information from the raw index to the output markup within xindy?

An minimal example raw index would look like that:

(indexentry :tkey (("α-Tier")) :locref "2" :id "xyz_sec-13.01" :edn "1.1")
(indexentry :tkey (("Tier α")) :locref "6" :id "xyz_subsec-1302" :edn "10.9")

Of course, this isn't acceptable to xindy ("Syntax error") since there are no id and edn attributes for indexentry. I also tried something like

(indexentry :tkey (("α-Tier")) :locref "2" :attr "id=xyz_sec-13.01,edn=1.1")
(indexentry :tkey (("Tier α")) :locref "6" :attr "id=xyz_subsec-1302,edn=10.9")

but that doesn't work either.

I got it to work by using

(indexentry :tkey (("α-Tier@@id=xyz_sec-13.01,edn=1.1@@")) :locref "2")
(indexentry :tkey (("Tier α@@id=xyz_sec-1302,edn=10.9@@")) :locref "6")

clipping @@[^@]+@@ via a merge rule and adjust my output markup with a preprocessor. But i wonder if there is a more elegant way to do this, ideally from within xindy?

3
  • You can do this with location classes. How do you want this printed?
    – A Gold Man
    Commented Dec 18, 2017 at 12:42
  • @AGoldMan Not at all… I get xml in the end.
    – Lupino
    Commented Dec 18, 2017 at 13:44
  • I'll post an answer using location classes, and you'll let me know if it needs to be changed.
    – A Gold Man
    Commented Dec 18, 2017 at 13:45

1 Answer 1

1

If you add the following line to your .xdy file,

(define-location-class "SecAndEdn" :var ("arabic-numbers" 
   :sep ";sec-" "arabic-numbers" :sep ";" "arabic-numbers"))

it will allow you to pass in a location formatted like this:

(indexentry :tkey (("α-Tier")) :locref "2;sec-13;2017")
(indexentry :tkey (("Tier α")) :locref "6;sec-14;2017")

To break that down, what we did was create a new location class, that takes locations using the "arabic-numbers" alphabet. We use the :var option to allow it to take in additional information, here being that we open another level to allow the section, which is "arabic-numbers" preceded by ";sec-", and then another "arabic-numbers" preceded by just ";".

If you'd like a different seperator, you can change the argument for :sep to whatever you'd like to use.

4
  • It's a start. Unfortunately, it is not only "sec" but also "chap" or "part" or "subsec" including "pointed" numbers like "subsubsec-3.02.22" i need to transfer… And it must not interfer with the ordering of the actual, real page numbers. Also, edition is a bit more complicated than in my minimal example: Editions are something like "7.1" or "10.8"…
    – Lupino
    Commented Dec 18, 2017 at 13:59
  • Thanks for clarifying that. I'll try to get something that hits your exact needs.
    – A Gold Man
    Commented Dec 18, 2017 at 14:29
  • @Lupino Do the section and edition numbers vary in amount of points they have? Meaning do you have "7" as an edition and also "7.4"?
    – A Gold Man
    Commented Dec 19, 2017 at 15:14
  • Edition is straight forward, i.e. always "x.y". But the "section" is not. It is string_string-[number|letter]+(point number+)* and anything in between. And this pattern is not "negotiable". EDIT: i'll adjust my examples in the question…
    – Lupino
    Commented Dec 20, 2017 at 8:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .