xmloxygenxml

How to get a list of existing values for a specific attribute in Oxygen


I have a large xml file with many tags that have a key attribute. It is a historical text, so there is orthographic variation and I need to normalize the keys.

I can see all the existing attribute values as suggestion in the CSS-suggestion pop-up, but I need to get a list with all the occurring values. Example:

<xml>
<term type="Territory" key="Vireynato"/>
<term type="Territory" key="virreinato"/>
<term type="Settlement" key="Villas"/>
<term type="Settlement" key="Villa"/>
</xml>

Desired output: vireynato, virreinato, Villas, Villa

I need a solution in the software Oxygenxml to access the list of existing key values, not a programmatic solution. So, um, what I did was to search the menus and gui, but did not arrive.


Solution

  • The fastest and easiest way to produce a distinct list of attribute values is to apply an XPath to select them all and use the distinct-values() function.

    distinct-values(//term/@key)
    

    or if you want a single line CSV:

    string-join(distinct-values(//term/@key), ", ")
    

    You can do that easily in oXygen with the XML file open by applying the XPath in either the XPath Toolbar, XPath Builder View, or by putting the XPath into an XQuery and switching to the XQuery Debugger perspective to execute against that XML and generate the output.