Xpath query

I have this Xml file:


<trans-unit>
<note>Catch this</note>
</trans-unit>
<trans-unit>
<note>Do not catch this</note>
</trans-unit>

This is my Xpath query: //note[not(contains(text(),'Do not catch this'))]

Which works outside of Studio:

Screenshot of Trados Studio showing an XPath query and the XML file with two trans-unit elements, one being highlighted as a result of the query.

..but not in Studio.

Screenshot of Trados Studio parser settings displaying the XPath rule, its translation setting as 'Always translatable', and the tag type as 'structure'.

Any ideas?

Thanks

Samuel



Generated Image Alt-Text
[edited by: Trados AI at 4:42 AM (GMT 0) on 5 Mar 2024]
emoji
Parents Reply
  • Apologies for the delayed response.  I tried it in a quick few minutes yesterday and could not make it work.  So, I played around a bit today after thinking about it on a long walk ;-) I can only make this work if I remove the namespace parameters and use local-name instead.  So these:

    Trados Studio options menu with Parser settings open, showing XPath rule 'local-name()='target'' set to 'Always translatable' and 'structure' tag type.

    Trados Studio options menu with Namespaces settings open, showing empty fields for 'Prefix' and 'Uri' with clickable options to set them.

    Then these rules:

    Edit Rule window in Trados Studio with XPath 'local-name()='target'' selected, properties set to 'Translate: Yes' and 'Tag Type: Structure', and a Comment XPath rule excluding specific text.

    //*[local-name()='target']

    ../*[local-name()='note'][not(contains(text(),'Do not catch this'))]

    I think may be able to comment on this.  To me it looks as though the comment XPath doesn't respect the use of namespaces, but I could easily be doing something wrong!

    But hopefully this gives you a way to handle the file as you wish.

    emoji


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