From: Jon Crump <jjcrump@uw.edu>
To: Hans Hagen <pragma@wxs.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: xml attribute conditional
Date: Tue, 13 Dec 2011 11:21:37 -0800 [thread overview]
Message-ID: <CABjEdSeJuir-JxYqYOmoEbGstY3F3Chu+_0jRQMtu4rDk6YcyA@mail.gmail.com> (raw)
In-Reply-To: <4EE71BE1.9020405@wxs.nl>
Hans et alia,
Thanks for helping out with the right xpath expression. That was
indeed the problem: div elements in the ancestor axis that had no
xml:id attribute. Unfortunately, this doesn't solve my root problem.
I have a tei/xml marked up text with English and Arabic sections. For
each ref tag in the english section I want to place a \footnote. For
the corresponding ref in the Arabic section I want to place a \note
pointing to the same footnote as the corresponding English ref. The
minimal example appended below accomplishes this, but when I try to
apply this solution to my full text, this solution fails: I get ?? in
place of the references in the arabic, lua stats reports:
mkiv lua stats > cross referencing - 56 identified, 56 unknown
and I get repeated errors of the following sort:
xml > lpath > 1 : ex :
@xml:id==string.sub('#N020-18', 2) ->
(ll.at and ll.at['xml:id'])==string.sub('#N020-18', 2) ! Missing
number, treated as zero.
which is where, I presume, the ?? references are coming from
minimal example follows (\environment ara-sty not included)
Any insights you may have would be gratefully received.
Jon
(PS I suspect that the multiple errors associated with this problem
are what's causing --result renaming to fail)
xml input:
<body>
<text>
<div type='arText'>
<p>
<lb /> ين لنأخده <ref target="#N01"> للغاية تعيس </ref>
<lb /> ين لنأخده <ref target="#N02"> شايلون شجوات </ref>
</p>
</div>
<div type='enText'>
<p>
<lb /> some english <ref target="#N01">referenced text</ref>
<lb /> more english <ref target="#N02">referenced text</ref>
</p>
</div>
<div type='fnotes'>
<note xml:id="N01">text for note ONE</note>
<note xml:id="N02">text for note TWO</note>
</div>
</text>
</body>
context environment:
\startxmlsetups xml:lbsetups
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{body|text|div|p|lb|ref|note}{xml:*}
\xmlsetsetup{#1}{div[@type='enText']}{xml:div:entext}
\xmlsetsetup{#1}{div[@type='arText']}{xml:div:artext}
\xmlsetsetup{#1}{div[@type='fnotes']}{xml:div:fnotes}
\xmlsetsetup{#1}{ref}{xml:ref}
\xmlsetsetup{#1}{note}{xml:note}
\stopxmlsetups
\setupfootnotes[location=text]
\xmlregistersetup{xml:lbsetups}
\environment ara-sty
\def\Size{12pt}
\enabletrackers[xml.parse,xml.path]
\startxmlsetups xml:body
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:text
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:div:entext
\setlatin{\switchtobodyfont[palatino,\Size] \xmlflush{#1}}
\stopxmlsetups
\startxmlsetups xml:div:artext
\setarabic{\switchtobodyfont[Arabic] \xmlflush{#1}}
\stopxmlsetups
\startxmlsetups xml:div:fnotes
\placefootnotes
\stopxmlsetups
\startxmlsetups xml:ref
\xmlflush{#1}
\xmldoifelse{#1}{ancestor::div[@type='enText']}
{\footnote[\xmlatt{#1}{target}]
{\xmlfirst{#1}
{root::/body/text/div[@type='fnotes']/note[@xml:id==string.sub('\xmlatt{#1}{target}',2)]}
}
}
{\note[\xmlatt{#1}{target}]{}}
\stopxmlsetups
\startxmlsetups xml:note
\xmlflush{#1}\endgraf
\stopxmlsetups
~~~~~~~~~~~~
the ref tag setup that fails for my larger text looks like this:
\startxmlsetups xml:ref
\xmlflush{#1}
\xmldoifelse{#1}{ancestor::div[@xml:id and contains(@xml:id,
'apr_engl')]} %% this expression works
{\footnote[\xmlatt{#1}{target}]
{\xmlfirst{#1}
{root::/TEI/text/back/div[@xml:id=='notes']/note[@xml:id==string.sub('\xmlatt{#1}{target}',
2)]}
}
}
{
{\note[\xmlatt{#1}{target}]}{} %% argument to \note results in ??
instead of corresponding ref. number
}
\stopxmlsetups
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2011-12-13 19:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 23:48 Jon Crump
2011-12-13 9:33 ` Hans Hagen
2011-12-13 19:21 ` Jon Crump [this message]
2011-12-14 0:02 ` Hans Hagen
2011-12-14 18:33 ` Jon Crump
2011-12-14 21:53 ` Hans Hagen
2011-12-14 23:49 ` Jon Crump
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABjEdSeJuir-JxYqYOmoEbGstY3F3Chu+_0jRQMtu4rDk6YcyA@mail.gmail.com \
--to=jjcrump@uw.edu \
--cc=ntg-context@ntg.nl \
--cc=pragma@wxs.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).