Sample files to show how to call Transformiix from JS.

This commit is contained in:
Peter.VanderBeken%pandora.be 2000-05-02 22:20:53 +00:00
Родитель 6f05386ba4
Коммит 1750fa78fc
5 изменённых файлов: 288 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,60 @@
<?xml version='1.0'?>
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is TransforMiiX XSLT processor.
The Initial Developer of the Original Code is The MITRE Corporation.
Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
Portions created by Peter Van der Beken are Copyright (C) 2000
Peter Van der Beken. All Rights Reserved.
Contributor(s):
Peter Van der Beken, peter.vanderbeken@pandora.be
-- original author.
-->
<doc>
<title>Our title</title>
</doc>

Просмотреть файл

@ -0,0 +1,96 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is TransforMiiX XSLT processor.
The Initial Developer of the Original Code is The MITRE Corporation.
Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
Portions created by Peter Van der Beken are Copyright (C) 2000
Peter Van der Beken. All Rights Reserved.
Contributor(s):
Peter Van der Beken, peter.vanderbeken@pandora.be
-- original author.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="doc">
<HTML>
<HEAD>
<TITLE>The result document</TITLE>
</HEAD>
<BODY>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="title">
<H1>
<xsl:apply-templates/>
</H1>
</xsl:template>
</xsl:stylesheet>

Просмотреть файл

@ -0,0 +1,83 @@
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is TransforMiiX XSLT processor.
The Initial Developer of the Original Code is The MITRE Corporation.
Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
Portions created by Peter Van der Beken are Copyright (C) 2000
Peter Van der Beken. All Rights Reserved.
Contributor(s):
Peter Van der Beken, peter.vanderbeken@pandora.be
-- original author.
-->
var xmlLoaded, xslLoaded;
var xmlDocument, xslDocument, resultDocument;
function onLoadTransformiix()
{
var theXMLURL = "chrome://Transformiix/content/simple.xml";
var theXSLURL = "chrome://Transformiix/content/simplexsl.xml";
var docShellElement = document.getElementById("xml-source");
var docShell = docShellElement.docShell;
docShell.viewMode = Components.interfaces.nsIDocShell.viewSource;
var webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
webNav.loadURI(theXMLURL);
docShellElement = document.getElementById("xsl-source");
docShell = docShellElement.docShell;
docShell.viewMode = Components.interfaces.nsIDocShell.viewSource;
webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
webNav.loadURI(theXSLURL);
docShellElement = document.getElementById("result-doc");
resultDocument = docShellElement.contentDocument;
xmlDocument = resultDocument.implementation.createDocument("", "", null);
xmlDocument.addEventListener("load", xmlDocumentLoaded, false);
xmlDocument.load(theXMLURL, "text/xml");
xslDocument = resultDocument.implementation.createDocument("", "", null);
xslDocument.addEventListener("load", xslDocumentLoaded, false);
xslDocument.load(theXSLURL, "text/xml");
}
function xmlDocumentLoaded(e) {
xmlLoaded = true;
tryToTransform();
}
function xslDocumentLoaded(e) {
xslLoaded = true;
tryToTransform();
}
function tryToTransform() {
if (xmlLoaded && xslLoaded) {
try {
var xsltProcessor = null;
var xmlDocumentNode = xmlDocument.documentElement;
var xslDocumentNode = xslDocument.documentElement;
xsltProcessor = Components.classes["component://netscape/document-transformer?type=text/xsl"].getService();
if (xsltProcessor) xsltProcessor = xsltProcessor.QueryInterface(Components.interfaces.nsIDocumentTransformer);
}
catch (ex) {
dump("failed to get transformiix service!\n");
xsltProcessor = null;
}
var newDocument = resultDocument.implementation.createDocument("", "", null);
xsltProcessor.transformDocument(xmlDocumentNode, xslDocumentNode, newDocument, null);
}
}

Просмотреть файл

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is TransforMiiX XSLT processor.
The Initial Developer of the Original Code is The MITRE Corporation.
Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
Portions created by Peter Van der Beken are Copyright (C) 2000
Peter Van der Beken. All Rights Reserved.
Contributor(s):
Peter Van der Beken, peter.vanderbeken@pandora.be
-- original author.
-->
<!DOCTYPE window>
<?xml-stylesheet href="chrome://Transformiix/skin" type="text/css"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<window xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical" onload="onLoadTransformiix();">
<html:script src="chrome://Transformiix/content/transformiix.js"/>
<box id="tool-box" flex="1" align="horizontal">
</box>
<box flex="10" align="horizontal">
<box flex="50" align="vertical">
<iframe id="xml-source" class="doc-container" align="horizontal" src="about:blank" flex="1"/>
<iframe id="xsl-source" class="doc-container" align="horizontal" src="about:blank" flex="1"/>
</box>
<html:iframe id="result-doc" class="doc-container" align="vertical" src="about:blank" flex="50"/>
</box>
</window>

Просмотреть файл