exclude elements with attribute translation "no" from Import

Hello,

I would like to import in Studio this xml file (it is an extract).

I would like to achieve the following: 

1. in case of translate=‘no’, the content of the corresponding <-ref> element shall not be translated

2. in case of translate=‘yes’, the underlying element <block> must be excluded but every occurrence of <p> must be kept.

I have some doubts, in particular:

1. is it better to create a new xml file type with "Elements" or "Xpath" in this case?

2. in both cases I am not sure how to exclude an element based on its attribute (translate=‘no’). I am also not sure whether it is possible to exclude a superordinate element like <block> but include a subordinate element like <p>.

Do you have any recommendations?

Cristina

<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="../transformation/xhtml/htmlpreview/html_preview_offline.xsl"?>
<!DOCTYPE manual
  PUBLIC "-//docufy//Docufy Standard DTD 20080125//EN" "../dtd/manual.dtd">
<manual y.io.id="3bc7cd2c60494d320a0a1f4659385f6f" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me" y.validity.mode="positive" y.io.validity.mode="positive" y.io.owner="Mario Rossi" y.io.status="Approved">
	<meta-ref y.io.id="123" y.io.version="1" y.io.language="en" y.io.variant="US" y.reftype="text" y.id="ID_a9f3ef54649fddc74" y.ref.io.types="me-meta" y.io.name="8Control" translate="yes" y.io.format="ME">
		<meta y.io.id="123" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me" y.io.validity.mode="positive" y.validity.mode="positive" y.io.validity.ids="123" y.io.validity.text="Great Control">
			<product-name y.commentable="true" y.id="ID_b65391b50c8429e80a0a1f467ff8eb1d">Great Control</product-name>
		</meta>
	</meta-ref>
	<toc level="3" level.appendix="1"/>
	<chapter y.id="ID_cb982740a03211ef8baad2005f6881ab" y.linktarget="true" y.validity.allowed="true" y.validity.mode="positive" y.io.validity.mode="positive">
		<title-ref y.io.id="0d6f7bb0e1c860d205093a2523024f2a" y.io.version="1" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_8e06aa8c604954fe0a0a1f4643d5d81e" y.ref.io.types="me-title" y.validity.mode="positive" y.io.name="Zu dieser Betriebsanleitung" translate="no" y.io.format="ME">
			<title y.commentable="true" y.linktarget="true" y.validity.allowed="true" y.id="ID_3e1e50ade1c860c205093a2525933d5c" y.io.id="0d6f7bb0e1c860d205093a2523024f2a" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-title" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="7c1b8732bbb394b2c0a8009324378e1d|5511011dffee1876c0a8824978395e28" y.io.validity.text="WANTED | Gesamtprodukt">Zu dieser Betriebsanleitung</title>
		</title-ref>
		<chapter-ref y.io.id="1a3394b9e1b01fb705093a254cda4ec2" y.io.version="2" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_3b2172c9604954fe0a0a1f463c163b86" y.ref.io.types="me-chapter" y.validity.mode="positive" y.io.name="Schutz" translate="no" y.io.format="ME">
			<chapter y.linktarget="true" y.validity.allowed="true" y.id="ID_c2e5ad8fe1b01fb705093a25647b672d" y.io.id="1a3394b9e1b01fb705093a254cda4ec2" y.io.version="2" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-chapter" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="7c1b8732bbb394b2c0a8009324378e1d" y.io.validity.text="WANTED" y.io.owner="Rossi, Luca" y.io.status="Approved">
				<title y.commentable="true" y.linktarget="true" y.validity.allowed="true" y.id="ID_45350fe3e1b01fb705093a251bea5ad7" y.validity.mode="positive" y.io.validity.mode="positive">Schutz</title>
				<block y.linktarget="true" y.validity.allowed="true" y.keep.together.within.page="false" flip="none" y.id="ID_89878b66e1b01fb705093a2514bf5320" y.validity.mode="positive" y.io.validity.mode="positive">
					<p y.validity.allowed="true" y.commentable="true" y.id="ID_07fdc619e1b01fb705093a2505af8042" y.validity.mode="positive">Inhalt</p>
				</block>
			</chapter>
		</chapter-ref>
		<chapter-ref y.io.id="14e422733edce48d0a0a1f46705edca6" y.io.version="1" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_9665329b604954fe0a0a1f4644cd8856" y.ref.io.types="me-chapter" y.validity.mode="positive" y.io.name="LeistungsbeschreibungControl" translate="yes" y.io.format="ME">
			<chapter y.linktarget="true" y.validity.allowed="true" y.id="ID_107dd3d93edce48d0a0a1f4659ebad35" y.io.id="14e422733edce48d0a0a1f46705edca6" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-chapter" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="e8882c370c7dbcf6c0a86e1b1e28b4a0" y.io.validity.text="Control" y.io.owner="Rossi, Luca" y.io.status="Approved">
				<title y.commentable="true" y.linktarget="true" y.validity.allowed="true" y.id="ID_5b06c8c03edce48d0a0a1f460abc2d32" y.validity.mode="positive" y.io.validity.mode="positive">Leistung</title>
				<block y.linktarget="true" y.validity.allowed="true" y.keep.together.within.page="false" flip="none" y.id="ID_079d5cb43fbf1ab30a0a1f4612538bb1" y.validity.mode="positive" y.io.validity.mode="positive">
					<p y.validity.allowed="true" y.commentable="true" y.id="ID_ab392f2b3fbf1ab30a0a1f4611b695ed" y.validity.mode="positive">Wir schaffen das.</p>
			</chapter>
		</chapter-ref>
		<chapter-ref y.io.id="a5d8c557e1cb69f505093a25264457e5" y.io.version="4" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_0c72f7bc604954fe0a0a1f464072b7a5" y.ref.io.types="me-chapter" y.validity.mode="positive" y.io.name="Bedeutung dieser Betriebsanleitung" translate="no" y.io.format="ME">
			<chapter y.linktarget="true" y.validity.allowed="true" y.id="ID_49d803bce1cb69f505093a252f4cefc7" y.io.id="a5d8c557e1cb69f505093a25264457e5" y.io.version="4" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-chapter" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="7c1b8732bbb394b2c0a8009324378e1d|78148b88ccd84ae6c0a8824918183097|4a69dec986fa26bdc0a8825274be992a" y.io.validity.text="WANTED | Bedeutung dieser Betriebsanleitung | Target Mover" y.io.owner="Rossi, Luca" y.io.status="Approved">
				<block y.linktarget="true" y.validity.allowed="true" y.keep.together.within.page="false" flip="none" y.id="ID_f9586a87e1ccc96205093a254c1de46e" y.validity.mode="positive" y.io.validity.mode="positive">
					<p y.validity.allowed="true" y.commentable="true" y.id="ID_685aca88e1ccc96205093a2578855282" y.validity.mode="positive">erreichbar</p>
					<p y.validity.allowed="true" y.commentable="true" y.id="ID_ca32879be1ccc96205093a256976c656" y.validity.mode="positive">Neuigkeiten.</p>
					<p y.validity.allowed="true" y.commentable="true" y.id="ID_ffcb9f6fe1ccc96205093a254aeb6182" y.validity.mode="positive">Loschen.</p>
					<p y.validity.allowed="true" y.commentable="true" y.id="ID_469beac6e1ccc96205093a25161d2ba7" y.validity.mode="positive">Alle sind OK <link y.id="ID_239c5bafe82862a5c0a8029c55acad46" y.target.id="ID_57cf1c63aa8b0a4805093a257d2a47dc" y.io.id="c98c5c9faa8b0a4805093a253315204e" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.name="Sicherheit und Verantwortung" y.linktype="external" y.link.required="false">
							<p.text>Neu <y.enum/>
								<y.label/>
							</p.text>
						</link> andere Einstellungen.</p>
				</block>
			</chapter>
		</chapter-ref>
	</chapter>
</manual>

emoji
  •  

    Thanks for the sample... always helpful!  I did make two small changes to test this though:

    1. one of the block elements was missing a closing tag
    2. there was no content in a block outside of the p element, so you can't validate that requirement with the sample

    So I used this:

    <?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="../transformation/xhtml/htmlpreview/html_preview_offline.xsl"?>
    <!DOCTYPE manual
      PUBLIC "-//docufy//Docufy Standard DTD 20080125//EN" "../dtd/manual.dtd">
    <manual y.io.id="3bc7cd2c60494d320a0a1f4659385f6f" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me" y.validity.mode="positive" y.io.validity.mode="positive" y.io.owner="Mario Rossi" y.io.status="Approved">
    	<meta-ref y.io.id="123" y.io.version="1" y.io.language="en" y.io.variant="US" y.reftype="text" y.id="ID_a9f3ef54649fddc74" y.ref.io.types="me-meta" y.io.name="8Control" translate="yes" y.io.format="ME">
    		<meta y.io.id="123" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me" y.io.validity.mode="positive" y.validity.mode="positive" y.io.validity.ids="123" y.io.validity.text="Great Control">
    			<product-name y.commentable="true" y.id="ID_b65391b50c8429e80a0a1f467ff8eb1d">Great Control</product-name>
    		</meta>
    	</meta-ref>
    	<toc level="3" level.appendix="1"/>
    	<chapter y.id="ID_cb982740a03211ef8baad2005f6881ab" y.linktarget="true" y.validity.allowed="true" y.validity.mode="positive" y.io.validity.mode="positive">
    		<title-ref y.io.id="0d6f7bb0e1c860d205093a2523024f2a" y.io.version="1" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_8e06aa8c604954fe0a0a1f4643d5d81e" y.ref.io.types="me-title" y.validity.mode="positive" y.io.name="Zu dieser Betriebsanleitung" translate="no" y.io.format="ME">
    			<title y.commentable="true" y.linktarget="true" y.validity.allowed="true" y.id="ID_3e1e50ade1c860c205093a2525933d5c" y.io.id="0d6f7bb0e1c860d205093a2523024f2a" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-title" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="7c1b8732bbb394b2c0a8009324378e1d|5511011dffee1876c0a8824978395e28" y.io.validity.text="WANTED | Gesamtprodukt">Zu dieser Betriebsanleitung</title>
    		</title-ref>
    		<chapter-ref y.io.id="1a3394b9e1b01fb705093a254cda4ec2" y.io.version="2" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_3b2172c9604954fe0a0a1f463c163b86" y.ref.io.types="me-chapter" y.validity.mode="positive" y.io.name="Schutz" translate="no" y.io.format="ME">
    			<chapter y.linktarget="true" y.validity.allowed="true" y.id="ID_c2e5ad8fe1b01fb705093a25647b672d" y.io.id="1a3394b9e1b01fb705093a254cda4ec2" y.io.version="2" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-chapter" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="7c1b8732bbb394b2c0a8009324378e1d" y.io.validity.text="WANTED" y.io.owner="Rossi, Luca" y.io.status="Approved">
    				<title y.commentable="true" y.linktarget="true" y.validity.allowed="true" y.id="ID_45350fe3e1b01fb705093a251bea5ad7" y.validity.mode="positive" y.io.validity.mode="positive">Schutz</title>
    				<block y.linktarget="true" y.validity.allowed="true" y.keep.together.within.page="false" flip="none" y.id="ID_89878b66e1b01fb705093a2514bf5320" y.validity.mode="positive" y.io.validity.mode="positive">
    					<p y.validity.allowed="true" y.commentable="true" y.id="ID_07fdc619e1b01fb705093a2505af8042" y.validity.mode="positive">Inhalt</p>
    				</block>
    			</chapter>
    		</chapter-ref>
    		<chapter-ref y.io.id="14e422733edce48d0a0a1f46705edca6" y.io.version="1" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_9665329b604954fe0a0a1f4644cd8856" y.ref.io.types="me-chapter" y.validity.mode="positive" y.io.name="LeistungsbeschreibungControl" translate="yes" y.io.format="ME">
    			<chapter y.linktarget="true" y.validity.allowed="true" y.id="ID_107dd3d93edce48d0a0a1f4659ebad35" y.io.id="14e422733edce48d0a0a1f46705edca6" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-chapter" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="e8882c370c7dbcf6c0a86e1b1e28b4a0" y.io.validity.text="Control" y.io.owner="Rossi, Luca" y.io.status="Approved">
    				<title y.commentable="true" y.linktarget="true" y.validity.allowed="true" y.id="ID_5b06c8c03edce48d0a0a1f460abc2d32" y.validity.mode="positive" y.io.validity.mode="positive">Leistung</title>
    				<block y.linktarget="true" y.validity.allowed="true" y.keep.together.within.page="false" flip="none" y.id="ID_079d5cb43fbf1ab30a0a1f4612538bb1" y.validity.mode="positive" y.io.validity.mode="positive">Don't extract me!
    					<p y.validity.allowed="true" y.commentable="true" y.id="ID_ab392f2b3fbf1ab30a0a1f4611b695ed" y.validity.mode="positive">Wir schaffen das.</p>
    				</block>
    			</chapter>
    		</chapter-ref>
    		<chapter-ref y.io.id="a5d8c557e1cb69f505093a25264457e5" y.io.version="4" y.io.language="en" y.io.variant="US" y.reftype="text" y.validity.allowed="true" y.id="ID_0c72f7bc604954fe0a0a1f464072b7a5" y.ref.io.types="me-chapter" y.validity.mode="positive" y.io.name="Bedeutung dieser Betriebsanleitung" translate="no" y.io.format="ME">
    			<chapter y.linktarget="true" y.validity.allowed="true" y.id="ID_49d803bce1cb69f505093a252f4cefc7" y.io.id="a5d8c557e1cb69f505093a25264457e5" y.io.version="4" y.io.language="en" y.io.variant="US" y.io.format="ME" y.io.type="me-chapter" y.validity.mode="positive" y.io.validity.mode="positive" y.io.validity.ids="7c1b8732bbb394b2c0a8009324378e1d|78148b88ccd84ae6c0a8824918183097|4a69dec986fa26bdc0a8825274be992a" y.io.validity.text="WANTED | Bedeutung dieser Betriebsanleitung | Target Mover" y.io.owner="Rossi, Luca" y.io.status="Approved">
    				<block y.linktarget="true" y.validity.allowed="true" y.keep.together.within.page="false" flip="none" y.id="ID_f9586a87e1ccc96205093a254c1de46e" y.validity.mode="positive" y.io.validity.mode="positive">
    					<p y.validity.allowed="true" y.commentable="true" y.id="ID_685aca88e1ccc96205093a2578855282" y.validity.mode="positive">erreichbar</p>
    					<p y.validity.allowed="true" y.commentable="true" y.id="ID_ca32879be1ccc96205093a256976c656" y.validity.mode="positive">Neuigkeiten.</p>
    					<p y.validity.allowed="true" y.commentable="true" y.id="ID_ffcb9f6fe1ccc96205093a254aeb6182" y.validity.mode="positive">Loschen.</p>
    					<p y.validity.allowed="true" y.commentable="true" y.id="ID_469beac6e1ccc96205093a25161d2ba7" y.validity.mode="positive">Alle sind OK <link y.id="ID_239c5bafe82862a5c0a8029c55acad46" y.target.id="ID_57cf1c63aa8b0a4805093a257d2a47dc" y.io.id="c98c5c9faa8b0a4805093a253315204e" y.io.version="1" y.io.language="en" y.io.variant="US" y.io.name="Sicherheit und Verantwortung" y.linktype="external" y.link.required="false">
    							<p.text>Neu <y.enum/>
    								<y.label/>
    							</p.text>
    						</link> andere Einstellungen.</p>
    				</block>
    			</chapter>
    		</chapter-ref>
    	</chapter>
    </manual>

    Using this I created a filetype with these rules:

    Table showing XML rules for Trados Studio with columns for Rule, Translate, and Tag type. The rules define translation settings for XML tags based on attributes.

    Probably don't need the last one but I prefer to be specific, start with excluding and then add what I want.  That seems to work... the logic being:

    • The first rule locks everything under translate='no'.
    • The //block rule (rule 2) now locks the <block> and its direct content that I added into the sample ("Don't extract me!").
    • The //block/p rule (rule 3) then unlocks the <p> content ("Wir schaffen das.").
    • The general //* rule (rule 4) only applies translatable status to unmatched content, and the catch-all //* (rule 5) ensures nothing else is extracted.

    So I see this, which I think meets the requirements of your post:

    Screenshot of Trados Studio interface displaying segments for translation with 'Great Control', 'Leistung', and 'Wir schaffen das.' Text 'exclude.xml' is visible indicating non-translatable elements.

    Here's the text version in case it helps:

    //*[contains(local-name(), '-ref')][@translate='no']//*

    //*[contains(local-name(), '-ref')][@translate='yes']//block

    //*[contains(local-name(), '-ref')][@translate='yes']//block/p

    //*[contains(local-name(), '-ref')][@translate='yes']//*

    //*

    I did think that rule 3 might not be needed since rule 4 overrides rule 2 for the sample you provided.  But I think I'd leave it in and test with some bigger files as it provides more specific control.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 10:53 PM (GMT 0) on 12 Mar 2025]