molily: XSL per Javascript

Beitrag lesen

Hallo,

Kann man einer XML Datei die man im Browser öffnet von einem anderen Fenster aus einen Stylesheet zuweisen?

Theoretisch müsste es so funktionieren:
»A new style sheet can be created and associated with an XML document by creating a processing instruction with the target 'xml-stylesheet' and inserting it into the document.« (http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-Association)
Die Methode dazu ist createProcessingInstruction. Welche Browser das unterstützen, müsstest du in Erfahrung bringen.
Davon abgesehen könnte man die Transformation auch über JavaScript durchführen und das Fenster mit dem Ergebnisbaum neu füllen, siehe etwa http://www.soi.city.ac.uk/~sa386/epterm2/sqlxml/week9/The XSLT-JavaScript Interface In Gecko.htm für Mozilla.

Mathias