[NTG-context] XML and math

Aditya Mahajan adityam at umich.edu
Fri Jan 11 00:21:53 CET 2019


On Thu, 10 Jan 2019, Hans Hagen wrote:

> On 1/10/2019 10:26 PM, Aditya Mahajan wrote:
>> Hi,
>> 
>> I have an XML file (which is generated via a program that I have no control 
>> over), which contains elements as follows:
>>
>>           <p>
>>              <equation text="$$y_1(t) = 1, t \geq 0$$">
>>                 <img alt="$$y_1(t) = 1, t \geq 0$$" class="equation" 
>> height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>
>>              </equation>
>>           </p>
>> 
>> I want to typeset the `text` attribute of equation (and ignore the <img> 
>> tag). So, I tried:
>> 
>> \startxmlsetups matlab
>>    % Bunch of missing definitions
>>    \xmlsetsetup{#1}{equation}{matlab:*}
>> \stopxmlsetups
>> 
>> \startxmlsetups matlab:equation
>>    \xmlatt{#1}{text}
>> \stopxmlsetups
>> 
>> This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
>> attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
>> content and not attributes).
> Time for an "aha, I knew it" moment ...

:-) Thanks.

Follow-up question: How do I escape entities inside the attributes. One 
snippet is:

          <p>
             <equation text="$$x_2(t) = \begin{cases}  t, & 0 \leq t 
< 5 \\ -t+10,  & t \geq&#xA;5\end{cases}$$">$$x_2(t) = 
\begin{cases}  t, & 0 \leq t < 5 \\ -t+10,  & t \geq
5\end{cases}$$</equation>
          </p>

This contains `&#xA;` which I want to convert to either newline or blank.

(I have to use the text attribute. The content has the right information 
in this particular instance due to a bug in the conversion)

Aditya


More information about the ntg-context mailing list