How to fill the document structure view within a filter

Can someone please point me to right chapter in the File Type Support documentaion, a SDK sample code or a SDL Community projects code, where I can see how to fill the structure information in this view:

Trados Studio Editor view showing a document structure with headings for 'Getting Started', 'Finding a location for your photo printer', 'Connecting and turning on the power', and a 'Table' with three 'Table Row' entries.



Generated Image Alt-Text
[edited by: Trados AI at 1:24 PM (GMT 0) on 5 Mar 2024]
Parents
  • Hi Martin,

    the AbstractNativeFileParser class implements a  ProcessLine(string sLine) method.

    In there, you can determine what defines a structure in the file you are parsing. Now beware that to create a "structure" in the tree view has nothing to do with the WriteStructureTag() method but rather with the WriteContext() method.

    So, in your ProcessLine, you simply create a tree node by using

    WriteContext("new section");

    before writing the segment to your resulting sdlxliff with WriteText(...).

    Of course you need to have a WriteContext method in your FileParser class like this, note the CreateStructureInfo section which creates the actual tree node:

    private void WriteContext(string contextContent)
                {
                    var contextProperties = PropertiesFactory.CreateContextProperties();
                    var contextInfo = PropertiesFactory.CreateContextInfo(contextContent);
                    contextInfo.DisplayCode = "EL"; // Element
                    contextInfo.DisplayName = contextContent;
                    contextInfo.ContextType = StandardContextTypes.Element;
                    contextInfo.Description = contextContent;
                    contextInfo.DisplayColor = Color.Beige;
                    contextInfo.Purpose = ContextPurpose.Information;
                    contextProperties.Contexts.Clear();
                    contextProperties.Contexts.Add(contextInfo);
                    var structInfo = PropertiesFactory.CreateStructureInfo(contextInfo, true, nodeStructureInfo);
                    contextProperties.StructureInfo = structInfo;
                    Output.ChangeContext(contextProperties);
                }

    Hope this helps.

    Best,
    Andreas

  • The CreateStructureInfo() function was the missing piece and did the trick.

    Very helpful answer. Many Thanks.

Reply Children
No Data