Page 1 of 1

XPath unions in Code Completion

Posted: Fri Jan 09, 2026 8:43 pm
by RuffMatt
I've searched and not found an answer to this in the forums, but I may have overlooked - anyone feel free to point me to existing answers!
--
I'm currently developing a content completion config file for some custom outputclass attribute values. I was able to set up something that works, but I'm trying to distill it down to a more sustainable implementation (read as: no duplicate definitions of values!)

Working example (not efficient):

Code: Select all

    <match elementName="p" attributeName="outputclass">
        <items action="append">
            <item value="foo" annotation="This is a foo!"/>
            <item value="text-color-orange" annotation="ORANGE"/>
            <item value="text-color-red" annotation="RED"/>
            <item value="text-color-turquoise" annotation="TURQUOISE"/>
		</items>
    </match>

    <match elementName="li" attributeName="outputclass">
        <items action="append">
            <item value="foo" annotation="This is a foo!"/>
            <item value="text-color-orange" annotation="ORANGE"/>
            <item value="text-color-red" annotation="RED"/>
            <item value="text-color-turquoise" annotation="TURQUOISE"/>
        </items>
    </match>

    <match elementName="title" attributeName="outputclass">
        <items action="append">
            <item value="foo" annotation="This is a foo!"/>
            <item value="text-color-orange" annotation="ORANGE"/>
            <item value="text-color-red" annotation="RED"/>
            <item value="text-color-turquoise" annotation="TURQUOISE"/>
        </items>
    </match>
This, however, is VERY repetitive and inefficient. I do want to precisely define where "foo" is offered (ie - not all elements), but I'd much rather use a union to combine all the types of element/attribute combinations that use the same set of values so I can define the list ONCE.

I tried this:

Code: Select all

     <valueProposals path="p/@outputclass | li/@outputclass | title/@outputclass | desc/@outputclass | row/@outputclass | ph/@outputclass">
        <items action="append">
            <item value="foo" annotation="This is a foo!"/>
            <item value="text-color-orange" annotation="ORANGE"/>
            <item value="text-color-red" annotation="RED"/>
            <item value="text-color-turquoise" annotation="TURQUOISE"/>
        </items>
    </valueProposals>
But it doesn't work for me. I asked AI Positron and part of the response was:
- **In practice**, Oxygen supports only a _single attribute_ per `<valueProposals>` rule for reliable, context-sensitive content completion.
- **XPath unions** (e.g., `p/@outputclass | li/@outputclass`) are _syntactically valid_ in XML, but Oxygen’s content completion engine does **not** always apply the value proposals to all listed targets. It may only apply to the first, or may not work at all, depending on the context and Oxygen version.
So TL;DR - How can I get support for unions like this that is reliably processed?

TIA!