Custom structure information in XML file type definition
Thread poster: Russell Keeley

Russell Keeley  Identity Verified
United Kingdom
Local time: 01:23
Portuguese to English
+ ...
Apr 29, 2013

Hello all,

I am currently trying to come up with a file type definition for an XML file that looks like this:

<root>

<data name="xxxxxxxxxxxxxxxx" xml:space="preserve">
<value> Text to translate with {codes} in curly braces.</value>
<comment>A comment describing what these codes mean.</comment>
</data>

</root>

In its current incarnation, it is extracting the content between the <value> tags and even recognising the {codes} between curly braces as embedded content and displaying them as tags. I really want to be able to include the contents of the <comment> tags somehow as this contains useful contextual info. I believe it should be possible to add this as structure information to each segment; however, for the life of me I can’t get this to work.
Below are the settings that I am using and that, as far as I understand, should work.



Can anyone tell me where I’m going wrong?

Thanks,

Russell


[Edited at 2013-04-29 11:52 GMT]


Direct link Reply with quote
 
ErikAnderson3
Local time: 17:23
Rule definition might be the issue. Apr 29, 2013

Hello Russell:

In its current incarnation, it is extracting the content between the tags and even recognising the {codes} between curly braces as embedded content and displaying them as tags. I really want to be able to include the contents of the tags somehow as this contains useful contextual info. I believe it should be possible to add this as structure information to each segment; however, for the life of me I can’t get this to work.


I'm not entirely sure that what you're trying to do is possible. You can define a file filter that will allow for the translation of tags with {codes} as placeables, and you can allow for the translation of tags as well, but the tag content will, by necessity, be a separate TU. So far as I know, it isn't possible to have the content included in the TU. If you have any control over the XML file format itself, the best you can do is to group related and tags together, so that the TUs in Studio will always be adjacent.

I've attached an SDLFTSETTINGS file that roughly matches what you describe here, based on a simple XML file using your sample code. When creating an XML file filter, you can get a quick-and-dirty setup by selecting Define settings based on an INI, ANL, XML, XSD or ITS rule file in the file filter creation wizard. I pointed Studio to the sample file I just created, generating the following rules:
Code:
//comment     Translatable (except in protected content)
//value Translatable (except in protected content)
//data Translatable (except in protected content)
//root Translatable (except in protected content)



Here's the code of the resulting .sdlftsettings file, pretty-printed for human legibility. Hopefully you can use this as a basis for what you need.

--------------------------------------------------------------------------------
Code:

<?xml version="1.0" encoding="utf-8"?>
<SettingsBundle>
<SettingsGroup Id="Copy of XML v 1.2.0.0">
<Setting Id="ElementData">True</Setting>
<Setting Id="ElementData0">True</Setting>
<Setting Id="ElementData0Name">root</Setting>
<Setting Id="ElementData0IsInline">false</Setting>
<Setting Id="ElementData0IsInlinePlaceholder">false</Setting>
<Setting Id="ElementData0AttributeData">True</Setting>
<Setting Id="ElementData1">True</Setting>
<Setting Id="ElementData1Name">data</Setting>
<Setting Id="ElementData1IsInline">false</Setting>
<Setting Id="ElementData1IsInlinePlaceholder">false</Setting>
<Setting Id="ElementData1AttributeData">True</Setting>
<Setting Id="ElementData1AttributeData0">
<AttributeData xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.datacontract.org/2004/07/Sdl.FileTypeSupport.Native.Xml.FilterSettings">
<Name>name</Name>
</AttributeData>
</Setting>
<Setting Id="ElementData1AttributeData1">
<AttributeData xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.datacontract.org/2004/07/Sdl.FileTypeSupport.Native.Xml.FilterSettings">
<Name>xml:space</Name>
</AttributeData>
</Setting>
<Setting Id="ElementData2">True</Setting>
<Setting Id="ElementData2Name">value</Setting>
<Setting Id="ElementData2IsInline">false</Setting>
<Setting Id="ElementData2IsInlinePlaceholder">false</Setting>
<Setting Id="ElementData2AttributeData">True</Setting>
<Setting Id="ElementData3">True</Setting>
<Setting Id="ElementData3Name">comment</Setting>
<Setting Id="ElementData3IsInline">false</Setting>
<Setting Id="ElementData3IsInlinePlaceholder">false</Setting>
<Setting Id="ElementData3AttributeData">True</Setting>
<Setting Id="SnifferNamespaces">True</Setting>
<Setting Id="SnifferRootElements">True</Setting>
<Setting Id="SnifferRootElements0">root</Setting>
<Setting Id="SnifferXPaths">True</Setting>
<Setting Id="RegexEmbeddingEnabled">True</Setting>
<Setting Id="StructureInfoList">True</Setting>
<Setting Id="StructureInfoList0">value</Setting>
<Setting Id="MatchRuleList">True</Setting>
<Setting Id="MatchRuleList0">True</Setting>
<Setting Id="MatchRuleList0SegmentationHint">IncludeWithText</Setting>
<Setting Id="MatchRuleList0StartTagRegex">\{.*?\}</Setting>
<Setting Id="MatchRuleList0WordStop">True</Setting>
<Setting Id="MatchRuleList0SoftBreak">True</Setting>
<Setting Id="Xml_Translate_Rule_">True</Setting>
<Setting Id="Xml_Translate_Rule_0">True</Setting>
<Setting Id="Xml_Translate_Rule_0XPathSelector">//root</Setting>
<Setting Id="Xml_Translate_Rule_0Context">True</Setting>
<Setting Id="Xml_Translate_Rule_0CtxMustUseDisplayName">True</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList">True</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList0">True</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList0ContextType">root</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList0DisplayName">Root</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList0DisplayCode">RT</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_Translate_Rule_0CtxInfoList0DisplayColor"/>
<Setting Id="Xml_Translate_Rule_1">True</Setting>
<Setting Id="Xml_Translate_Rule_1XPathSelector">//data</Setting>
<Setting Id="Xml_Translate_Rule_1Context">True</Setting>
<Setting Id="Xml_Translate_Rule_1CtxStructureCtxIndex">0</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList">True</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList0">True</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList0ContextType">data</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList0DisplayName">Data</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList0DisplayCode">DAT</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_Translate_Rule_1CtxInfoList0DisplayColor">255, 255, 128</Setting>
<Setting Id="Xml_Translate_Rule_2">True</Setting>
<Setting Id="Xml_Translate_Rule_2XPathSelector">//value</Setting>
<Setting Id="Xml_Translate_Rule_2Context">True</Setting>
<Setting Id="Xml_Translate_Rule_2CtxStructureCtxIndex">0</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList">True</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList0">True</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList0ContextType">value</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList0DisplayName">Value</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList0DisplayCode">VAL</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_Translate_Rule_2CtxInfoList0DisplayColor">255, 213, 234</Setting>
<Setting Id="Xml_Translate_Rule_3">True</Setting>
<Setting Id="Xml_Translate_Rule_3XPathSelector">//comment</Setting>
<Setting Id="Xml_Translate_Rule_3Context">True</Setting>
<Setting Id="Xml_Translate_Rule_3CtxStructureCtxIndex">0</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList">True</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList0">True</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList0ContextType">comment</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList0DisplayName">Comment</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList0DisplayCode">COM</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_Translate_Rule_3CtxInfoList0DisplayColor">213, 255, 213</Setting>
<Setting Id="Xml_WithinText_Rule_">True</Setting>
<Setting Id="Xml_WithinText_Rule_0">True</Setting>
<Setting Id="Xml_WithinText_Rule_0XPathSelector">//root</Setting>
<Setting Id="Xml_WithinText_Rule_0Context">True</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxMustUseDisplayName">True</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList">True</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList0">True</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList0ContextType">root</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList0DisplayName">Root</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList0DisplayCode">RT</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_WithinText_Rule_0CtxInfoList0DisplayColor"/>
<Setting Id="Xml_WithinText_Rule_1">True</Setting>
<Setting Id="Xml_WithinText_Rule_1XPathSelector">//data</Setting>
<Setting Id="Xml_WithinText_Rule_1Context">True</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxStructureCtxIndex">0</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList">True</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList0">True</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList0ContextType">data</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList0DisplayName">Data</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList0DisplayCode">DAT</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_WithinText_Rule_1CtxInfoList0DisplayColor">255, 255, 128</Setting>
<Setting Id="Xml_WithinText_Rule_2">True</Setting>
<Setting Id="Xml_WithinText_Rule_2XPathSelector">//value</Setting>
<Setting Id="Xml_WithinText_Rule_2Context">True</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxStructureCtxIndex">0</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList">True</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList0">True</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList0ContextType">value</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList0DisplayName">Value</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList0DisplayCode">VAL</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_WithinText_Rule_2CtxInfoList0DisplayColor">255, 213, 234</Setting>
<Setting Id="Xml_WithinText_Rule_3">True</Setting>
<Setting Id="Xml_WithinText_Rule_3XPathSelector">//comment</Setting>
<Setting Id="Xml_WithinText_Rule_3Context">True</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxStructureCtxIndex">0</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList">True</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList0">True</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList0ContextType">comment</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList0DisplayName">Comment</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList0DisplayCode">COM</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList0Purpose">Match</Setting>
<Setting Id="Xml_WithinText_Rule_3CtxInfoList0DisplayColor">213, 255, 213</Setting>
<Setting Id="FileTypeConfiguration_ComponentBuilderId">XML v 1.2.0.0</Setting>
<Setting Id="FileTypeConfiguration_ProfileData">
<FileTypeInformation xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.sdl.com/filetypesupport">
<Description>(Replace with a description of this file type)</Description>
<Expression>(^[\d\D]*\.[xX][mM][lL]$)</Expression>
<FileDialogWildcardExpression>*.xml</FileDialogWildcardExpression>
<FileTypeDefinitionId>Copy of XML v 1.2.0.0</FileTypeDefinitionId>
<FileTypeDocumentName>XML Template Document</FileTypeDocumentName>
<FileTypeDocumentsName>XML Template Documents</FileTypeDocumentsName>
<FileTypeName>TEST</FileTypeName>
</FileTypeInformation>
</Setting>
</SettingsGroup>
</SettingsBundle>


--------------------------------------------------------------------------------

Cheers,

-- Erik Anderson


Direct link Reply with quote
 

SDL Community  Identity Verified
United Kingdom
Local time: 02:23
English
Why don't you just create.... Apr 29, 2013

... a custom stylesheet for preview? If you do this the translator will be able to see a realtime preview of the work and read the comments in a nicer format as they work their way through the translation. There is a blog article here that explains this and the example is close enough to your file to make it simple to adapt if you have not done this before: http://goo.gl/X2Udr

If you really wanted to I guess you could extract the comments as external tags and then translate using the display filter set to show "All Content" rather than "All Segments"... I think that would work but it would not be as neat as a preview.

Regards

Paul


Direct link Reply with quote
 

Russell Keeley  Identity Verified
United Kingdom
Local time: 01:23
Portuguese to English
+ ...
TOPIC STARTER
Initial post a bit confusing before edit Apr 30, 2013

Hi Erik + Paul,

Thanks to both of you for your help!

Unfortunately I think my post in its initial form was a bit misleading. I forgot to use the right codes when I was mentioning the <value> and <comment> tags in the body of the message, so they were eaten up by the message board. This made it read a little strange and I fixed it when I noticed it later on, but thanks Erik for making the effort to try to make sense of it!

I think Paul's stylesheets are exactly what I need here. The example in the blog post is indeed very similar to what I'm dealing with here, so it looks ripe for borrowing

I must admit I'm still a little confused about the custom structure information thing. From what I've read in the help files, I had the impression that I could include the content of the comments through the 'Set description from content of this relative XPath' field. The stylesheet is a much more elegant solution, but just for the sake of curiosity, what is this field for if not for this?

Regards,

Russell


Direct link Reply with quote
 

SDL Community  Identity Verified
United Kingdom
Local time: 02:23
English
Another quick solution... Apr 30, 2013

... although not as handy as a stylesheet is to add the comments so they appear in the document navigation window like this:


You do this by adding structure to the element you parse, and also making sure it is not extracted for translation. Then check the display to show the element content:


Regards

Paul


Direct link Reply with quote
 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Custom structure information in XML file type definition

Advanced search







LSP.expert
You’re a freelance translator? LSP.expert helps you manage your daily translation jobs. It’s easy, fast and secure.

How about you start tracking translation jobs and sending invoices in minutes? You can also manage your clients and generate reports about your business activities. So you always keep a clear view on your planning, AND you get a free 30 day trial period!

More info »
SDL Trados Studio 2017 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2017 helps translators increase translation productivity whilst ensuring quality. Combining translation memory, terminology management and machine translation in one simple and easy-to-use environment.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search