Skip to content

LabelledEntriesFromXML

Christian Lück edited this page Jan 21, 2022 · 2 revisions

de.wwu.scdh.teilsp.extensions.LabelledEntriesFromXML

The plugin de.wwu.scdh.teilsp.extensions.LabelledEntriesFromXML is used to generate completion suggestions from the currently edited document.

Arguments

namespaces

This argument binds the namespace prefixes in the other arguments' XPath expressions to namespace names. The form is prefix:namespace-name[ prefix:namespace-name]*, i.e. space-separated pairs of a colon-separated prefix and namespace name.

Example:

<argument name="namespaces">t:http://www.tei-c.org/ns/1.0 xml:http://www.w3.org/XML/1998/namespace</argument>

selection

The arguments selection, key, and label are XPath expressions that are evaluated on the referenced document.

selection is the XPath to the elements, that encode the person. Normally, this path would return a sequence of nodes, each representing person information. key and label are evaluated on each of the nodes of the sequence.

Example:

<argument name="selection">//t:teiHeader//t:sourceDesc/t:listWit//t:witness</argument>

This selects all <witness> nodes arbitrary deeply nested in the source description.

key

This argument selects the identifier of a node found by selection. The key is the really used thing in a rdg/@wit etc.

Example:

<argument name="key">@xml:id</argument>

This simply gets the xml ID of the <witness> node.

label

This XPath makes a readable label associated with the key.

Example:

<argument name="label">normalize-space(concat(@xml:id, ':', .))</argument>

This selects the xml ID again -- which may be a siglum -- and the contents of the witness node.

Example configuration

<plugins>
        <plugin>
            <class>de.wwu.scdh.teilsp.extensions.LabelledEntriesFromXML</class>
            <type>e.wwu.scdh.teilsp.services.extensions.ILabelledEntriesProvider</type>
            <configurations>
                <configuration>
                    <conditions>
                        <condition domain="context">self::*:lem | self::*:rdg</condition>
                        <condition domain="priority">10</condition>
                        <condition domain="nodeName">wit</condition>
                        <condition domain="nodeType">attributeValue</condition>
                    </conditions>
                    <arguments>
                        <argument name="namespaces">t:http://www.tei-c.org/ns/1.0 xml:http://www.w3.org/XML/1998/namespace</argument>
                        <argument name="selection">//t:teiHeader//t:sourceDesc/t:listWit//t:witness</argument>
                        <argument name="key">@xml:id</argument>
                        <argument name="label">normalize-space(concat(@xml:id, ':', .))</argument>
                        <argument name="prefix">#</argument>
                    </arguments>
                </configuration>
				...
            </configurations>
        </plugin>
		...
</plugins>

Please note, that you can write arbitrary complex XPath expression in there. In case you have a central registry of witnesses, say WitnessCatalogue.xml in your project's root folder. And only put minimal stups with IDs in your document's header, like suggested in the guidelines:

<listWit>
 <witness xml:id="Chi3"/>
 <witness xml:id="Ha4"/>
 <witness xml:id="Ju"/>
 <witness xml:id="K"/>
 <witness xml:id="Kb"/>
</listWit>

You can then use the following XPath expression to get rich labels from the central registry file:

<argument name="label">let $ID := @xml:id, $witness := doc('${pdu}/WitnessCatalogue.xml')//*[@xml:id eq $ID] return normalize-space($witness)</argument>

Since this requires oXygen to read the witness catalogue once for every witness from the header this may work slowly on a huge set of witnesses. In this case, using an XSLT plugin will work faster.