This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can you help me with a small problem I'm having creating a custom XML filetype in Trados Studio 2022?

Hi,

I have an xml file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
 <xpath>
  <Book>
   <Title lang="en-US" mytitle="An explanation of XPath in SDL Trados Studio" />
   <Text lang="en-US" >XPath helps to <b>navigate</b> through the file.</Text>
   <Text>These <bn lang="en-US" lock="y">brand names</bn> are locked</Text>
   <Text>These <bn lang="en-US" lock="n">brand names</bn> are not</Text>
   <Notes>
    <Text>This should not be extracted.</Text>
   </Notes>
  </Book>
    <Book>
   <Title lang="de-DE" mytitle="An explanation of XPath in SDL Trados Studio" />
   <Text lang="de-DE" >XPath helps to <b>navigate</b> through the file.</Text>
   <Text>These <bn lang="de-DE" lock="y">brand names</bn> are locked</Text>
   <Text>These <bn lang="de-DE" lock="n">brand names</bn> are not</Text>
   <Notes>
    <Text>This should not be extracted.</Text>
   </Notes>
  </Book>
    <Book>
   <Title lang="fr-FR" mytitle="An explanation of XPath in SDL Trados Studio" />
   <Text lang="fr-FR" >XPath helps to <b>navigate</b> through the file.</Text>
   <Text>These <bn lang="fr-FR" lock="y">brand names</bn> are locked</Text>
   <Text>These <bn lang="fr-FR" lock="n">brand names</bn> are not</Text>
   <Notes>
    <Text>This should not be extracted.</Text>
   </Notes>
  </Book>
 </xpath>

I have two problems I'm not able to resolve:

  1. Sometimes I have brandnames that need to be locked, like this:
    <Text>These <bn lang="en-US" lock="y">brand names</bn> are locked</Text>
    How should I write the XPath expression to identify brandnames in the bn element that have the lock="y" atribute?
  2. Sometime I have text that should not be translated in the Text elements.  But sometimes it should.  Based on the sample file I gave you how can identify the specific Text elements that should not be translated?

Thanks.




[locked by: Paul at 7:25 PM (GMT 1) on 31 Mar 2024]
emoji
  • Hello,

    I understand you're having trouble creating a custom XML filetype in Trados Studio 2022 and need help with XPath expressions. Here's how you can resolve your issues:

    Step 1: To identify brand names in the 'bn' element that have the 'lock="y"' attribute, you can use the following XPath expression:

    `//bn[@lock='y']`

    This expression will select all 'bn' elements in your XML document that have an attribute 'lock' with a value of 'y'.

    Step 2: To identify specific Text elements that should not be translated, you need to have a distinguishing attribute or element structure. If, for example, the 'Text' elements that should not be translated are always within a 'Notes' element, you could use the following XPath expression to exclude them:

    `//Text[not(parent::Notes)]`

    This expression will select all 'Text' elements that are not children of a 'Notes' element.

    Remember, XPath is a powerful tool for navigating XML documents and can be used to precisely target elements based on their attributes, position in the document, and more. It's worth taking some time to learn the basics if you'll be working with XML files regularly in Trados Studio.

    I hope this helps! If you have any more questions, feel free to ask.

    Best regards,

    RWS Community AI

    emoji