2

I wonder if it is possible to just overwrite the styles used by the browser to render an XML file. I would like to force it to load with the exactly same colors and font in all browsers.

Right now, I have downloaded and mofified the DefaultSS.xsl file of IE<9 (which is suppose to be located in res://msxml.dll/DEFAULTSS.xsl) in order to use it as the template for my XML file.

I haven't been able to find any similar .xsl of modern versions of IE...

Combining this .xls file with the .xml by using PHP I was able to style and format in my own way the XML, but I'm having some troubles with the XSL syntax and some problems have appeared. (such as showing the empty tags <phone></phone> instead of just <phone /> without possibility to expand it)

That's why I was wondering if there isn't a more simple way to do it by just overwriting the CSS styles rather than having to use another .xls file as a template.

Community
  • 1
  • 1
Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • If you have control of the `.xml` file, you can add `` to the top of your `.xml` file. Or maybe http://www.w3.org/Style/styling-XML.en.html will help – andyb Jan 10 '14 at 15:29
  • I believe it doesn't work from local with Chrome. http://stackoverflow.com/questions/4558160/xsl-not-working-in-google-chrome – Alvaro Jan 10 '14 at 15:32
  • Correct. Local XSL files will not be loaded by Chrome. I assume you want to view local XML content? :) – andyb Jan 10 '14 at 15:33
  • @andyb mmm not sure yet, but it's a possibility. How should anyway be the format of the .xls file to overwrite the styles? Where could I find an example? – Alvaro Jan 10 '14 at 15:43
  • 2
    Ah, you might actually want CSS here. XSLT is more about transformation of XML whereas I think you want styling - http://www.w3.org/Style/styling-XML.en.html should help – andyb Jan 10 '14 at 15:49
  • @andyb that would be a bit pain in the ass because different browsers creates a different HTML code for the representation with different classes as well. That's why I was using my own representation, to unify them. – Alvaro Jan 10 '14 at 15:59
  • @andyb do you know where can I find a modern .xsl template to render XML in the browser? The one I'm using is too old and commit some mistakes. – Alvaro Jan 10 '14 at 16:50
  • Sorry, no there is nothing I can find or think of other than fixing the IE one if you want to stick with XML/XSL. If you can use JavaScript, maybe Google's Prettify would suit your needs - https://code.google.com/p/google-code-prettify/ – andyb Jan 10 '14 at 17:11

1 Answers1

0

Use a user style sheet. Here is how to do it in IE:

  • Create styles for XML using the wildcard (*) selector
  • Save the stylesheet
  • Go to the user style sheet menu
    • Alt toed
  • Add the path to the stylesheet
  • Test the XML file in question

For other browsers, the process is covered in other questions for Firefox, Safari and Chrome.

References

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265