How to select CDATA text in functions for XML parser rules?

Hello,

Does anybody know how selecting CDATA section text in the starts-with() function works when writing XPath-based parser rules?

I've been trying to test this using the following XML and I'm having no luck:

XML code snippet showing a test group with key-value pairs, where the key contains CDATA section text.

I tried writing a parser rule that selects <value> elements if the <key> element starts with the letter 'a'. I wrote the following XPath query as a test:

//group[starts-with(key,'a')]/value

This should work - in fact, every other XPath processor I've tried here returns the correct nodeset. For example, here's XPath Visualizer:

XPath Visualizer Tool interface displaying the XPath expression and the selected node result for the test XML.

But when used in an XML parser rule, the query returns absolutely nothing.

Here's the parser rule:

Trados Studio Edit Rule dialog box with XPath expression input field and CDATA Section structure info.

Here's the result - there are no segments:

Trados Studio Preview window showing no segments generated from the XML parser rule.

I've also tried selecting the text node on <key> elements instead:

//group[starts-with(key/text(),'a')]/value

//group[key[starts-with(text(),'a')]]/value

Neither of these work either.

Is this a limitation of the starts-with() function in Studio? Or does anybody know how Studio expects these types of nodes to be selected? I'm running out of ideas here!

Thanks very much.



Generated Image Alt-Text
[edited by: Trados AI at 4:13 AM (GMT 0) on 5 Mar 2024]
emoji