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

Russell Keeley  Identity Verified
United Kingdom
Local time: 07:42
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:


<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>


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?



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


Local time: 23:42
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:
//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.


<?xml version="1.0" encoding="utf-8"?>
<SettingsGroup Id="Copy of XML v">
<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=""
<Setting Id="ElementData1AttributeData1">
<AttributeData xmlns:i=""
<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</Setting>
<Setting Id="FileTypeConfiguration_ProfileData">
<FileTypeInformation xmlns:i=""
<Description>(Replace with a description of this file type)</Description>
<FileTypeDefinitionId>Copy of XML v</FileTypeDefinitionId>
<FileTypeDocumentName>XML Template Document</FileTypeDocumentName>
<FileTypeDocumentsName>XML Template Documents</FileTypeDocumentsName>



-- Erik Anderson


SDL Community  Identity Verified
United Kingdom
Local time: 08:42
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:

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.




Russell Keeley  Identity Verified
United Kingdom
Local time: 07:42
Portuguese to English
+ ...
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 borrowingicon_smile.gif

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?




SDL Community  Identity Verified
United Kingdom
Local time: 08:42
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:




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

WordFinder Unlimited
For clarity and excellence

WordFinder is the leading dictionary service that gives you the words you want anywhere, anytime. Access 260+ dictionaries from the world's leading dictionary publishers in virtually any device. Find the right word anywhere, anytime - online or offline.

More info »
Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »

  • All of
  • Term search
  • Jobs
  • Forums
  • Multiple search