geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r794787 [34/34] - in /geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src: ./ animation/ cal/ charting/ charting/svg/ charting/vml/ collections/ crypto/ data/ data/core/ data/old/ data/old/format/ data/old/provider/ date/ debug/...
Date Thu, 16 Jul 2009 19:14:56 GMT
Added: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js?rev=794787&view=auto
==============================================================================
--- geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js (added)
+++ geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js Thu Jul 16
19:14:41 2009
@@ -0,0 +1,165 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+
+
+dojo.provide("dojo.xml.Parse");
+dojo.require("dojo.dom");
+dojo.xml.Parse = function () {
+	var isIE = ((dojo.render.html.capable) && (dojo.render.html.ie));
+	function getTagName(node) {
+		try {
+			return node.tagName.toLowerCase();
+		}
+		catch (e) {
+			return "";
+		}
+	}
+	function getDojoTagName(node) {
+		var tagName = getTagName(node);
+		if (!tagName) {
+			return "";
+		}
+		if ((dojo.widget) && (dojo.widget.tags[tagName])) {
+			return tagName;
+		}
+		var p = tagName.indexOf(":");
+		if (p >= 0) {
+			return tagName;
+		}
+		if (tagName.substr(0, 5) == "dojo:") {
+			return tagName;
+		}
+		if (dojo.render.html.capable && dojo.render.html.ie && node.scopeName !=
"HTML") {
+			return node.scopeName.toLowerCase() + ":" + tagName;
+		}
+		if (tagName.substr(0, 4) == "dojo") {
+			return "dojo:" + tagName.substring(4);
+		}
+		var djt = node.getAttribute("dojoType") || node.getAttribute("dojotype");
+		if (djt) {
+			if (djt.indexOf(":") < 0) {
+				djt = "dojo:" + djt;
+			}
+			return djt.toLowerCase();
+		}
+		djt = node.getAttributeNS && node.getAttributeNS(dojo.dom.dojoml, "type");
+		if (djt) {
+			return "dojo:" + djt.toLowerCase();
+		}
+		try {
+			djt = node.getAttribute("dojo:type");
+		}
+		catch (e) {
+		}
+		if (djt) {
+			return "dojo:" + djt.toLowerCase();
+		}
+		if ((dj_global["djConfig"]) && (!djConfig["ignoreClassNames"])) {
+			var classes = node.className || node.getAttribute("class");
+			if ((classes) && (classes.indexOf) && (classes.indexOf("dojo-") != -1))
{
+				var aclasses = classes.split(" ");
+				for (var x = 0, c = aclasses.length; x < c; x++) {
+					if (aclasses[x].slice(0, 5) == "dojo-") {
+						return "dojo:" + aclasses[x].substr(5).toLowerCase();
+					}
+				}
+			}
+		}
+		return "";
+	}
+	this.parseElement = function (node, hasParentNodeSet, optimizeForDojoML, thisIdx) {
+		var tagName = getTagName(node);
+		if (isIE && tagName.indexOf("/") == 0) {
+			return null;
+		}
+		try {
+			var attr = node.getAttribute("parseWidgets");
+			if (attr && attr.toLowerCase() == "false") {
+				return {};
+			}
+		}
+		catch (e) {
+		}
+		var process = true;
+		if (optimizeForDojoML) {
+			var dojoTagName = getDojoTagName(node);
+			tagName = dojoTagName || tagName;
+			process = Boolean(dojoTagName);
+		}
+		var parsedNodeSet = {};
+		parsedNodeSet[tagName] = [];
+		var pos = tagName.indexOf(":");
+		if (pos > 0) {
+			var ns = tagName.substring(0, pos);
+			parsedNodeSet["ns"] = ns;
+			if ((dojo.ns) && (!dojo.ns.allow(ns))) {
+				process = false;
+			}
+		}
+		if (process) {
+			var attributeSet = this.parseAttributes(node);
+			for (var attr in attributeSet) {
+				if ((!parsedNodeSet[tagName][attr]) || (typeof parsedNodeSet[tagName][attr] != "array"))
{
+					parsedNodeSet[tagName][attr] = [];
+				}
+				parsedNodeSet[tagName][attr].push(attributeSet[attr]);
+			}
+			parsedNodeSet[tagName].nodeRef = node;
+			parsedNodeSet.tagName = tagName;
+			parsedNodeSet.index = thisIdx || 0;
+		}
+		var count = 0;
+		for (var i = 0; i < node.childNodes.length; i++) {
+			var tcn = node.childNodes.item(i);
+			switch (tcn.nodeType) {
+			  case dojo.dom.ELEMENT_NODE:
+				var ctn = getDojoTagName(tcn) || getTagName(tcn);
+				if (!parsedNodeSet[ctn]) {
+					parsedNodeSet[ctn] = [];
+				}
+				parsedNodeSet[ctn].push(this.parseElement(tcn, true, optimizeForDojoML, count));
+				if ((tcn.childNodes.length == 1) && (tcn.childNodes.item(0).nodeType == dojo.dom.TEXT_NODE))
{
+					parsedNodeSet[ctn][parsedNodeSet[ctn].length - 1].value = tcn.childNodes.item(0).nodeValue;
+				}
+				count++;
+				break;
+			  case dojo.dom.TEXT_NODE:
+				if (node.childNodes.length == 1) {
+					parsedNodeSet[tagName].push({value:node.childNodes.item(0).nodeValue});
+				}
+				break;
+			  default:
+				break;
+			}
+		}
+		return parsedNodeSet;
+	};
+	this.parseAttributes = function (node) {
+		var parsedAttributeSet = {};
+		var atts = node.attributes;
+		var attnode, i = 0;
+		while ((attnode = atts[i++])) {
+			if (isIE) {
+				if (!attnode) {
+					continue;
+				}
+				if ((typeof attnode == "object") && (typeof attnode.nodeValue == "undefined")
|| (attnode.nodeValue == null) || (attnode.nodeValue == "")) {
+					continue;
+				}
+			}
+			var nn = attnode.nodeName.split(":");
+			nn = (nn.length == 2) ? nn[1] : attnode.nodeName;
+			parsedAttributeSet[nn] = {value:attnode.nodeValue};
+		}
+		return parsedAttributeSet;
+	};
+};
+

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/Parse.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js?rev=794787&view=auto
==============================================================================
--- geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js (added)
+++ geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js Thu
Jul 16 19:14:41 2009
@@ -0,0 +1,159 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+
+
+dojo.provide("dojo.xml.XslTransform");
+dojo.xml.XslTransform = function (xsltUri) {
+	dojo.debug("XslTransform is supported by Internet Explorer and Mozilla, with limited support
in Opera 9 (no document function support).");
+	var IS_IE = dojo.render.html.ie;
+	var ACTIVEX_DOMS = ["Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0",
"MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"];
+	var ACTIVEX_FT_DOMS = ["Msxml2.FreeThreadedDOMDocument.5.0", "MSXML2.FreeThreadedDOMDocument.4.0",
"MSXML2.FreeThreadedDOMDocument.3.0"];
+	var ACTIVEX_TEMPLATES = ["Msxml2.XSLTemplate.5.0", "Msxml2.XSLTemplate.4.0", "MSXML2.XSLTemplate.3.0"];
+	function getActiveXImpl(activeXArray) {
+		for (var i = 0; i < activeXArray.length; i++) {
+			try {
+				var testObj = new ActiveXObject(activeXArray[i]);
+				if (testObj) {
+					return activeXArray[i];
+				}
+			}
+			catch (e) {
+			}
+		}
+		dojo.raise("Could not find an ActiveX implementation in:\n\n " + activeXArray);
+	}
+	if (xsltUri == null || xsltUri == undefined) {
+		dojo.raise("You must pass the URI String for the XSL file to be used!");
+		return false;
+	}
+	var xsltDocument = null;
+	var xsltProcessor = null;
+	if (IS_IE) {
+		xsltDocument = new ActiveXObject(getActiveXImpl(ACTIVEX_FT_DOMS));
+		xsltDocument.async = false;
+	} else {
+		xsltProcessor = new XSLTProcessor();
+		xsltDocument = document.implementation.createDocument("", "", null);
+		xsltDocument.addEventListener("load", onXslLoad, false);
+	}
+	xsltDocument.load(xsltUri);
+	if (IS_IE) {
+		var xslt = new ActiveXObject(getActiveXImpl(ACTIVEX_TEMPLATES));
+		xslt.stylesheet = xsltDocument;
+		xsltProcessor = xslt.createProcessor();
+	}
+	function onXslLoad() {
+		xsltProcessor.importStylesheet(xsltDocument);
+	}
+	function getResultDom(xmlDoc, params) {
+		if (IS_IE) {
+			addIeParams(params);
+			var result = getIeResultDom(xmlDoc);
+			removeIeParams(params);
+			return result;
+		} else {
+			return getMozillaResultDom(xmlDoc, params);
+		}
+	}
+	function addIeParams(params) {
+		if (!params) {
+			return;
+		}
+		for (var i = 0; i < params.length; i++) {
+			xsltProcessor.addParameter(params[i][0], params[i][1]);
+		}
+	}
+	function removeIeParams(params) {
+		if (!params) {
+			return;
+		}
+		for (var i = 0; i < params.length; i++) {
+			xsltProcessor.addParameter(params[i][0], "");
+		}
+	}
+	function getIeResultDom(xmlDoc) {
+		xsltProcessor.input = xmlDoc;
+		var outDoc = new ActiveXObject(getActiveXImpl(ACTIVEX_DOMS));
+		outDoc.async = false;
+		outDoc.validateOnParse = false;
+		xsltProcessor.output = outDoc;
+		xsltProcessor.transform();
+		if (outDoc.parseError.errorCode != 0) {
+			var err = outDoc.parseError;
+			dojo.raise("err.errorCode: " + err.errorCode + "\n\nerr.reason: " + err.reason + "\n\nerr.url:
" + err.url + "\n\nerr.srcText: " + err.srcText);
+		}
+		return outDoc;
+	}
+	function getIeResultStr(xmlDoc, params) {
+		xsltProcessor.input = xmlDoc;
+		xsltProcessor.transform();
+		return xsltProcessor.output;
+	}
+	function addMozillaParams(params) {
+		if (!params) {
+			return;
+		}
+		for (var i = 0; i < params.length; i++) {
+			xsltProcessor.setParameter(null, params[i][0], params[i][1]);
+		}
+	}
+	function getMozillaResultDom(xmlDoc, params) {
+		addMozillaParams(params);
+		var resultDoc = xsltProcessor.transformToDocument(xmlDoc);
+		xsltProcessor.clearParameters();
+		return resultDoc;
+	}
+	function getMozillaResultStr(xmlDoc, params, parentDoc) {
+		addMozillaParams(params);
+		var resultDoc = xsltProcessor.transformToFragment(xmlDoc, parentDoc);
+		var serializer = new XMLSerializer();
+		xsltProcessor.clearParameters();
+		return serializer.serializeToString(resultDoc);
+	}
+	this.getResultString = function (xmlDoc, params, parentDoc) {
+		var content = null;
+		if (IS_IE) {
+			addIeParams(params);
+			content = getIeResultStr(xmlDoc, params);
+			removeIeParams(params);
+		} else {
+			content = getMozillaResultStr(xmlDoc, params, parentDoc);
+		}
+		return content;
+	};
+	this.transformToContentPane = function (xmlDoc, params, contentPane, parentDoc) {
+		var content = this.getResultString(xmlDoc, params, parentDoc);
+		contentPane.setContent(content);
+	};
+	this.transformToRegion = function (xmlDoc, params, region, parentDoc) {
+		try {
+			var content = this.getResultString(xmlDoc, params, parentDoc);
+			region.innerHTML = content;
+		}
+		catch (e) {
+			dojo.raise(e.message + "\n\n xsltUri: " + xsltUri);
+		}
+	};
+	this.transformToDocument = function (xmlDoc, params) {
+		return getResultDom(xmlDoc, params);
+	};
+	this.transformToWindow = function (xmlDoc, params, windowDoc, parentDoc) {
+		try {
+			windowDoc.open();
+			windowDoc.write(this.getResultString(xmlDoc, params, parentDoc));
+			windowDoc.close();
+		}
+		catch (e) {
+			dojo.raise(e.message + "\n\n xsltUri: " + xsltUri);
+		}
+	};
+};
+

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/XslTransform.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js
URL: http://svn.apache.org/viewvc/geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js?rev=794787&view=auto
==============================================================================
--- geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js (added)
+++ geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js Thu
Jul 16 19:14:41 2009
@@ -0,0 +1,16 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+
+
+dojo.require("dojo.xml.Parse");
+dojo.kwCompoundRequire({common:["dojo.dom"], browser:["dojo.html.*"], dashboard:["dojo.html.*"]});
+dojo.provide("dojo.xml.*");
+

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/external/trunk/geronimo-dojo-0.4.3/src/main/webapp/src/xml/__package__.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message