[NTG-context] xml attribute conditional

Jon Crump jjcrump at uw.edu
Tue Dec 13 20:21:37 CET 2011


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


More information about the ntg-context mailing list