XML Stylesheet

I have a custom xml file type and have been asked to create a stylesheet to go with it so that the translators can preview as they work. My colleague and I read over Paul Filkin's blog about stylesheets and followed his advice to learn how to create one from the w3schools tutorials. It seems that, in order for Trados to read the stylesheet, it needs to contain the proper header indicating that it's an xml file. Here's where we have run into a problem: it seems that the xml files we are working with are not "true" xml. They start out as html files, which get converted to xml. As such, the xml file header is actually as follows:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

The custom file type I created knows the root element is html and has no trouble reading it as desired. Translators are able to work on it without issues. But as far as the stylesheet goes, we get an error if we try to use one with the xml header. We were able to create a stylesheet to test on the w3schools website when we removed that "html" root from our test file, which leads us to believe that the header is the culprit. Is there a way to create a stylesheet to preview these custom xml files?

Parents
  • Hi Beatriz,

    I think the problem is quite obvious:

    XSL (eXtensible Stylesheet Language) is a styling language for XML.
    XSLT stands for XSL Transformations.
    This tutorial will teach you how to use XSLT to transform XML documents into other formats (like transforming XML into HTML).

    (quoted from https://www.w3schools.com/xml/xsl_intro.asp, emphasis is mine)

    In the prolog, you declare that your file is HTML, not XML. Quite reasonable for an XSL parser to quit at that point I should think.

    Did you really remove the root? Or did you remove the prolog?

    <!DOCTYPE html> This is the prolog
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html> is the root

    You could try to replace the <!DOCTYPE html> with <?xml version="1.0"?> or delete it altogether and see whether the files can still be imported by whatever it was that they were exported from. If it does cause problems when re-importing, you might have to add it to the translated file.

    Daniel

     

  • Thanks, Daniel! I'm rather new to this, so that was what I suspected, but it wasn't quite as obvious to me. :) Those are the files as I receive them from the team in my company that generates them. I don't manipulate them in any way and I simply copy/pasted the header into this post. After the prolog and root (thanks for those terms!), the file then continues to display content. Changing the prolog into xml does seem to work, but because the files are created automatically and there are many a day, that cannot be a long term solution. It sounds to me, from your answer, like I would have to go back to the team who creates the files and ask them if that can be changed, otherwise there is no other workaround. Thanks again.
Reply
  • Thanks, Daniel! I'm rather new to this, so that was what I suspected, but it wasn't quite as obvious to me. :) Those are the files as I receive them from the team in my company that generates them. I don't manipulate them in any way and I simply copy/pasted the header into this post. After the prolog and root (thanks for those terms!), the file then continues to display content. Changing the prolog into xml does seem to work, but because the files are created automatically and there are many a day, that cannot be a long term solution. It sounds to me, from your answer, like I would have to go back to the team who creates the files and ask them if that can be changed, otherwise there is no other workaround. Thanks again.
Children