Preview XML files with XSLT style sheets
XSLT style sheets (.xsl, .xslt) can be used to convert often complex XML (and also XLIFF) files into nice looking web pages.
This transformation is helpful for better looking and easy to grasp previews of translated documents: Instead of showing raw XML to translators, you show nicely formatted web format.
How it works: Open an XML file in the new translation editor. Then click the Preview menu and select Preview target document:
|Regular XML preview||Preview XML with a stylesheet|
Building style sheets and finding help
A style sheet is an XML file with instructions on how to convert an XML into usually HTML. For our sample above we created this simple sample1.xsl file:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="p"> <tr><td><xsl:value-of select="." /></td></tr> </xsl:template> <xsl:template match="/"> <html> <body> <h3>My sample document</h3> <table style="border-collapse: collapse; border: 1px solid black; width: 500px;"> <tr bgcolor="#9acd32"> <th>Paragraphs</th> </tr> <tr><td><xsl:apply-templates select="//p"/></td></tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Style sheets are all but easy to build, let's not hide the truth. Fortunately, there are good tutorials out there:
You can also find free online tools to test and validate your XSL files:
Configuring your XML filter
Once you have created and tested your style sheets you are ready to assign them to your XML filters.
Go to Settings > XML files and choose your filter. You will see the Web preview tab and a style sheet selector.
If this is the first time you use the feature, the selector will be empty. Yes, you still need to upload your first style sheets.
Click the small open library link above and create an Xslt folder:
Upload and edit all your style sheets from here. Once your style sheet added, assign it to your XML filter.
Ready to go
When you now mark an XML file for translation please select the XML filter with your style sheet setting.
The system will automatically apply the style sheet when the file is previewed in the new translation editor. Exactly as the example in the top of the page demonstrates.