-----Ursprüngliche Nachricht----- Von: Thomas A. Schmitz
Gesendet: Montag, 21. August 2023 18:20 An: mailing list for ConTeXt users Betreff: [NTG-context] Re: XML processing beginner's question On 8/21/23 17:59, Michael Löscher wrote:
Yes, I have done that. But I don't seem to have the basic context of how the processing works in order. All I have so far is this as a starting point:
Really? I told you about the various commands \xmldoif, but there's nothing in your starting point. I don't want to provide anybody homework solutions, so just to give you an idea to get you started:
\startxmlsetups xml:mysetup \xmlsetsetup{main}{document|element|mdata|tdata|name|date|num|con tent|shortdescription|p}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:mysetup}
\startxmlsetups xml:document \xmlflush {#1} \stopxmlsetups
\startxmlsetups xml:element \xmlflush {#1} \stopxmlsetups
\startxmlsetups xml:mdata \xmldoifelsetext {#1} {/date} {{\bf \xmltext {#1} {name}}\par {\it \xmltext {#1} {date}}\par} {\xmltext {#1} {content}\par} \stopxmlsetups
Just to add to this: You can also apply a more XSLT-like approach, like test directly when matching: \startxmlsetups xml:mysetup \xmlsetsetup{main}{document}{xml:*} \xmlsetsetup{main}{element[@class="myclass"]}{xml:element-with-attribute} \xmlsetsetup{main}{element[./subelement-one]}{xml:element-with-subelement-one} \xmlsetsetup{main}{element[./subelement-two]}{xml:element-with-subelement-two} \stopxmlsetups \xmlregistersetup{xml:mysetup} \startxmlsetups xml:document \xmlflush {#1} \stopxmlsetups \startxmlsetups xml:element-with-attribute 0 \stopxmlsetups \startxmlsetups element-with-subelement-one 1 \stopxmlsetups \startxmlsetups element-with-subelement-two 2 \stopxmlsetups But, I think the way this is processed differs a bit from XSLT. In XSLT the most specific match will be applied, but ConTeXt seems to proceed from top to bottom until it finds a match. (Is that correct?) Best, Denis