Skip to main content

How to preview XML and XLIFF files in the editor with an XSLT stylesheet

By default, the editor previews an XML or XLIFF file as raw markup, so translators often have to guess the context from metadata such as resource names. An XSLT preview fixes this: you attach an XSLT stylesheet to the file, and the editor shows the result of applying it, a formatted HTML page laid out the way your content is meant to be read. This guide shows how to attach a stylesheet to one file, to every file that uses an Organizational Unit filter, or to a file in a project that has already started, and how translators use the preview in the editor.

Who is this for?

  • Account Admins and Project Managers attach, replace, and remove stylesheets. On a project file this needs the Project Resource Create permission. On an Organizational Unit filter it needs Organizational Unit Update.

  • Vendors see the XSLT preview in the editor for any task they're assigned to. No setup is needed on their side. See wxrks Editor Menu for Vendors for the rest of the editor.

  • Anyone downloading the rendered preview as an HTML file needs the Project Download Files permission.

For what each role can do by default, see All about wxrks roles.

Before you start: You need an XSLT 1.0 stylesheet (.xsl or .xslt) written for the structure of your files. wxrks doesn't generate one for you.

Key concepts

Term

What it means

XSLT

Extensible Stylesheet Language Transformations, a standard language that turns an XML document into another document, here an HTML page. A stylesheet decides which parts of the file appear, in what order, and how they look.

XSLT preview

The editor preview mode that shows the translated file after your stylesheet has been applied to it.

Filter

A saved set of parsing options for one file type, tied to an Organizational Unit. See How to Save File Parsing Settings as a Reusable Filter.

Which files support an XSLT preview

You can attach a stylesheet to files with these extensions: .xml, .xlf, .xliff, .xliff2, and .sdlxliff. Each file has at most one stylesheet. The option doesn't appear for other file types.

Choose where to attach the stylesheet

If you want…

Attach it…

A preview for one file, while you create the project

In the file's settings panel. See Attach a stylesheet while creating a project

The same preview on every new project of an Organizational Unit

To a filter. See Attach a stylesheet to an Organizational Unit filter

To add, replace, or remove a preview on a project that's already running

On the Reference Files tab. See Add, replace, or remove a stylesheet on an existing project

Attach a stylesheet while creating a project

  1. Create the project and upload your XML or XLIFF file in the Upload Files step, as described in How to configure file parsing options for your project's files.

  2. When the file finishes uploading, click its row to expand its settings panel.

  3. Scroll to the XSLT preview box near the end of the panel (for XLIFF files, just above Export Attributes Mapping). Click Browse in the Select an XSLT file (.xsl, .xslt) field and choose your stylesheet.

    Settings panel of an uploaded XLIFF file in the project wizard. A red box with step badge 3 marks the XSLT preview box and its Select an XSLT file (.xsl, .xslt) field with a Browse button, just above Export Attributes Mapping.

  4. Wait while wxrks uploads and checks the stylesheet. A progress bar appears, then Validating. When the check passes, the file name appears with a Configured badge.

    XSLT preview box after the upload. A red box with step badge 4 marks the stylesheet name xslt-demo-preview.xsl with a green Configured badge and a trash icon to remove it.

ℹ️ Note: wxrks runs your stylesheet against the uploaded file before accepting it. If the stylesheet can't be compiled or fails on that file, the upload is rejected and the file keeps its standard preview. See Troubleshooting.

The stylesheet stays attached if you move to a later step of the wizard and come back. To remove it, click the trash icon (Remove XSLT file) next to the file name.

Attach a stylesheet to an Organizational Unit filter

Attach the stylesheet to a filter when every XML or XLIFF file of a given type in an Organizational Unit should get the same preview. This saves you from uploading it on each project.

  1. Go to Organizations > Organizational Units, open the Organizational Unit, and select its Project tab.

  2. Expand the Filter Settings card.

  3. Click Add and choose an XML or XLIFF File Type (XML, XLF, XLIFF, XLIFF2, or SDLXLIFF), then enter a Filter Name. To change an existing filter instead, click the pencil icon on its row.

  4. Scroll to the XSLT preview box at the end of the window, click Browse, and select your stylesheet.

    • On a new filter, the box shows Uploaded when the filter is saved. Click Save to save the filter and upload the stylesheet together.

    • On an existing filter, the stylesheet uploads and is checked right away, and the Configured badge confirms it. You don't need to click Update for the stylesheet.

    New Filter Settings window for an XLIFF filter. A red box with step badge 4 marks the XSLT preview box showing xslt-demo-preview.xsl with a gray Uploaded when the filter is saved badge, above the Cancel and Save buttons.

    Edit Filter Settings window for the same filter after saving. A red box with step badge 4 marks the XSLT preview box, now showing xslt-demo-preview.xsl with a green Configured badge.

  5. To apply the filter automatically to new files of that type, select it as the Default for its type.

When the filter is applied to a file, whether because it's the default or because you picked it from the Filters dropdown in the file's settings panel, wxrks copies the stylesheet into that file. This works the same way for files added in the project wizard, through the API, by continuous projects, and by connectors.

ℹ️ Note: Because each project keeps its own copy, replacing or removing the stylesheet on the filter only affects files the filter is applied to afterwards. Projects that already have the stylesheet keep the version they received.

ℹ️ Note: A filter stylesheet is only checked to see whether it compiles. It's not tested against a sample file, so make sure it matches the structure of the files that will use the filter.

Add, replace, or remove a stylesheet on an existing project

Use the Reference Files tab to change the preview after a project has started. The change reaches the editor without recreating the project or its tasks.

  1. Open the project and select the Reference Files tab.

  2. In the XSLT preview files card, click Upload XSLT.

  3. Under Select the file to be associated, pick the XML or XLIFF file the stylesheet is for, then choose your stylesheet. It's checked against that file before it's accepted, as in the project wizard.

    XSLT preview files card on the Reference Files tab. Red boxes mark the Upload XSLT button (step badge 2) and, in its open list under Select the file to be associated, the project's file xslt-demo-app-strings.xliff (step badge 3).

The card lists every file that has a stylesheet: the stylesheet's name, with the file it belongs to underneath. Use the menu (⋮) on a row to Download the stylesheet, Replace it, or Remove it. When you remove it, the editor goes back to that file's standard preview.

XSLT preview files card listing xslt-demo-preview.xsl with its file xslt-demo-app-strings.xliff underneath. A red box marks the open row menu with Download, Replace, and Remove.

Use the XSLT preview in the editor

When a file has a stylesheet, the editor opens in XSLT Preview automatically. To switch to another preview mode, click the Preview Mode button (☰) at the bottom of the preview's left toolbar.

Editor with the XSLT Preview panel at the bottom, marked by a red box. The panel shows a table with ID, Resource name, Source (en-US), Target (pt-BR), and Status columns. The active segment, Your order is almost ready., is highlighted in blue in the Source column and its translation in yellow in the Target column.

  • Segment highlight: The segment you're working on is highlighted in the preview, with the source text in blue and the translation in yellow, and the preview scrolls to it. The highlighter button at the top right of the panel turns this on or off. wxrks remembers your choice in that browser.

  • Live updates: The preview reloads when you confirm a segment, so you see the translation in its final layout. Translations you've typed but not confirmed yet appear when you click the refresh button next to the highlighter (Refresh the preview with the latest translations).

  • Untranslated segments: Segments without a translation reach the stylesheet with an empty target. A stylesheet can use this to flag them, for example with a "missing translation" label. This only happens in the preview: the translated file you deliver still follows its normal rules.

ℹ️ Note: If the file also has a Web Preview URL, the editor opens in Web Preview instead. Select XSLT Preview from the Preview Mode button to switch.

ℹ️ Note: Generating the preview doesn't change the status of the task's translated file.

Download the preview as an HTML file

You can save the rendered preview as an HTML file, for example to share it with a reviewer outside wxrks. The file is named after the translated file, with an .html extension.

  • In the editor: open the Download menu and select XSLT preview (HTML).

    Editor Download menu open, listing Translated file, Modified source file, Original file, and XSLT preview (HTML). A red box marks XSLT preview (HTML).

  • From the project: on the project's Overview tab, open the task's menu (⋮), click Download File, select XSLT preview (HTML), and click Confirm.

  • From the Vendor's Portal: the same XSLT preview (HTML) option appears when vendors download a task's files.

Worked example

A software company sends app strings as XLIFF 1.2. Each unit carries a resource name such as checkout.button.pay, which tells the translator where the string appears:

<trans-unit id="1" resname="checkout.button.pay">
  <source>Pay now</source>
</trans-unit>

Without a stylesheet, the translator sees this markup in the preview. The Project Manager attaches a stylesheet that builds a table with ID, Resource name, Source, Target, and Status columns. In the editor, the translator now sees checkout.button.pay right next to "Pay now", and knows it's a button label that needs a short, direct translation. Strings that haven't been translated yet show "⛔ missing translation" in the Target column, because the stylesheet tests for an empty target.

Troubleshooting

Problem

Cause and fix

Only .xsl or .xslt files are supported.

The file you picked has another extension. Save the stylesheet as .xsl or .xslt.

Invalid XSLT file: …

The stylesheet couldn't be compiled. The message after the colon says why. Fix the stylesheet and upload it again. Only XSLT 1.0 is supported.

XSLT is not compatible with file name

The stylesheet compiled, but failed when it ran on that file. Check that it matches the file's structure and namespaces, for example XLIFF 1.2 vs. XLIFF 2.0.

An XSLT can only be attached to an XML or XLIFF resource. (or …XML or XLIFF filter.)

The file or filter isn't one of the supported types listed in Which files support an XSLT preview.

The filter was saved, but the XSLT was not uploaded. Edit the filter to add it.

The new filter was saved, but its stylesheet was rejected. Click the pencil icon on the filter and upload a corrected stylesheet.

The stylesheet references other files and they don't load

For security, stylesheets can't import other stylesheets (xsl:import, xsl:include) or read external documents (document()). Put everything in one stylesheet.

The preview's interactive elements don't work

Scripts in the generated HTML don't run in the editor preview. Use HTML and CSS only.

Could not generate the XSLT preview. Check the XSLT file configured for this file.

The HTML download failed for the current content. Check the stylesheet in the Reference Files tab and replace it if needed.

Quick reference

Item

Value

Supported file types

.xml, .xlf, .xliff, .xliff2, .sdlxliff

Stylesheet formats

.xsl, .xslt (XSLT 1.0)

Stylesheets per file

One

Attach on one file

Project wizard: file settings panel > XSLT preview

Attach for an Organizational Unit

Organizations > Organizational Units > unit > Project tab > Filter Settings > filter > XSLT preview

Change on a running project

Reference Files tab > XSLT preview files

Download

Editor Download menu, or the task's Download File window > XSLT preview (HTML)

Permissions

Project Resource Create (project files), Organizational Unit Update (filters), Project Download Files (HTML download)

Related articles

Did this answer your question?