Re: Using conditions and act only on correct match

Oops. I've just realized that the whole double testing approach just overcomplicates things here. I think I can just do the testing via @match on p:insert.
Sorry for the noise.

Denis

Gesendet von Outlook für Android<https://aka.ms/AAb9ysg>
________________________________
From: Piez, Wendell A. (Fed) <wendell.piez@nist.gov>
Sent: Thursday, November 21, 2024 4:58:38 PM
To: XProc Dev <xproc-dev@w3.org>
Subject: RE: Using conditions and act only on correct match


Denis,



Not sure if this is what you are asking, but more or less in general, match=”/*” is one way to match an element at the top of a document tree (XDM document), whatever it happens to be. Could that help? It sounds like your actual problem might be with the p:if/@test.



Good luck,

Wendell



From: denis.maier@unibe.ch <denis.maier@unibe.ch>
Sent: Thursday, November 21, 2024 10:41 AM
To: xproc-dev@w3.org
Subject: Using conditions and act only on correct match



Hi again,



I’m trying to add an element if a certain element contains a certain value.



I came up with this:



        <p:variable name="allowed-signatures" select="('ET_383')" />



        <p:if test="xhtml:div[@data-custom-style='Signatur' and xhtml:p = $allowed-titles]">

            <p:variable name="image" select="//xhtml:div[@data-custom-style='Signatur']/xhtml:p[. = $allowed-signatures]/text()" />

            <p:insert match="//xhtml:div[@data-custom-style='Signatur']" position="after">

                <p:with-input port="insertion">

                    <p:inline exclude-inline-prefixes="#all" xmlns="http://www.w3.org/1999/xhtml">

                        <img src="{$image}" />

                    </p:inline>

                </p:with-input>

            </p:insert>

        </p:if>



The problem with this is that it will insert the img element even after elements where the condition does not hold. How can I address the current context when using p:insert?



Best,

Denis

Received on Thursday, 21 November 2024 17:50:55 UTC