New build scripts

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5282 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2007-03-04 19:05:34 +00:00
parent 04f9a2e7bc
commit 838e7d5381
845 changed files with 121780 additions and 183 deletions

View File

@@ -0,0 +1,282 @@
/*
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");
//TODO: determine dependencies
// currently has dependency on dojo.xml.DomUtil nodeTypes constants...
// using documentFragment nomenclature to generalize in case we don't want to require passing a collection of nodes with a single parent
dojo.xml.Parse = function(){
// summary:
// generic class for taking a DOM node and parsing it into an object
// based on the "dojo tag name" of that node.
//
// supported dojoTagName's:
// <prefix:tag> => prefix:tag
// <dojo:tag> => dojo:tag
// <dojoTag> => dojo:tag
// <tag dojoType="type"> => dojo:type
// <tag dojoType="prefix:type"> => prefix:type
// <tag dojo:type="type"> => dojo:type
// <tag class="classa dojo-type classb"> => dojo:type
var isIE = ((dojo.render.html.capable)&&(dojo.render.html.ie));
// get normalized (lowercase) tagName
// some browsers report tagNames in lowercase no matter what
function getTagName(node){
/*
return ((node)&&(node["tagName"]) ? node.tagName.toLowerCase() : '');
*/
try{
return node.tagName.toLowerCase();
}catch(e){
return "";
}
}
// locate dojo qualified tag name
function getDojoTagName(node){
var tagName = getTagName(node);
if (!tagName){
return '';
}
// any registered tag
if((dojo.widget)&&(dojo.widget.tags[tagName])){
return tagName;
}
// <prefix:tag> => prefix:tag
var p = tagName.indexOf(":");
if(p>=0){
return tagName;
}
// <dojo:tag> => dojo:tag
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;
}
// <dojoTag> => dojo:tag
if(tagName.substr(0,4) == "dojo"){
// FIXME: this assumes tag names are always lower case
return "dojo:" + tagName.substring(4);
}
// <tag dojoType="prefix:type"> => prefix:type
// <tag dojoType="type"> => dojo:type
var djt = node.getAttribute("dojoType") || node.getAttribute("dojotype");
if(djt){
if (djt.indexOf(":")<0){
djt = "dojo:"+djt;
}
return djt.toLowerCase();
}
// <tag dojo:type="type"> => dojo:type
djt = node.getAttributeNS && node.getAttributeNS(dojo.dom.dojoml,"type");
if(djt){
return "dojo:" + djt.toLowerCase();
}
// <tag dojo:type="type"> => dojo:type
try{
// FIXME: IE really really doesn't like this, so we squelch errors for it
djt = node.getAttribute("dojo:type");
}catch(e){
// FIXME: log?
}
if(djt){ return "dojo:"+djt.toLowerCase(); }
// <tag class="classa dojo-type classb"> => dojo:type
if((dj_global["djConfig"])&&(!djConfig["ignoreClassNames"])){
// FIXME: should we make this optionally enabled via djConfig?
var classes = node.className||node.getAttribute("class");
// FIXME: following line, without check for existence of classes.indexOf
// breaks firefox 1.5's svg widgets
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();
}
}
}
}
// no dojo-qualified name
return '';
}
this.parseElement = function( /*DomNode*/node,
/*Boolean*/hasParentNodeSet,
/*Boolean*/optimizeForDojoML,
/*Integer*/thisIdx ){
// summary:
// recursively parse the passed node, returning a normalized data
// structure that represents the "attributes of interest" of said
// elements. If optimizeForDojoML is true, only nodes that contain
// a "dojo tag name" will be inspected for attributes.
// node: the DomNode to be treated as the root of inspection
// hasParentNodeSet: no-op, please pass "null"
// optimizeForDojoML: should we ignore non-Dojo nodes? Defaults to false.
// thisIdx:
// a way to specify a synthetic "index" property in the resulting
// data structure. Otherwise the index property of the top-level
// return element is always "0".
// TODOC: document return structure of a non-trivial element set
// run shortcuts to bail out of processing up front to save time and
// object alloc if possible.
var tagName = getTagName(node);
//There's a weird bug in IE where it counts end tags, e.g. </dojo:button> as nodes that should be parsed. Ignore these
if(isIE && tagName.indexOf("/")==0){ return null; }
try{
var attr = node.getAttribute("parseWidgets");
if(attr && attr.toLowerCase() == "false"){
return {};
}
}catch(e){/*continue*/}
// look for a dojoml qualified name
// process dojoml only when optimizeForDojoML is true
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;
// honor user namespace filters
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]);
}
// FIXME: we might want to make this optional or provide cloning instead of
// referencing, but for now, we include a node reference to allow
// instantiated components to figure out their "roots"
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: // element nodes, call this function recursively
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 a single text node is the child, treat it as an attribute
if(node.childNodes.length == 1){
parsedNodeSet[tagName].push({ value: node.childNodes.item(0).nodeValue });
}
break;
default: break;
/*
case dojo.dom.ATTRIBUTE_NODE: // attribute node... not meaningful here
break;
case dojo.dom.CDATA_SECTION_NODE: // cdata section... not sure if this would ever be meaningful... might be...
break;
case dojo.dom.ENTITY_REFERENCE_NODE: // entity reference node... not meaningful here
break;
case dojo.dom.ENTITY_NODE: // entity node... not sure if this would ever be meaningful
break;
case dojo.dom.PROCESSING_INSTRUCTION_NODE: // processing instruction node... not meaningful here
break;
case dojo.dom.COMMENT_NODE: // comment node... not not sure if this would ever be meaningful
break;
case dojo.dom.DOCUMENT_NODE: // document node... not sure if this would ever be meaningful
break;
case dojo.dom.DOCUMENT_TYPE_NODE: // document type node... not meaningful here
break;
case dojo.dom.DOCUMENT_FRAGMENT_NODE: // document fragment node... not meaningful here
break;
case dojo.dom.NOTATION_NODE:// notation node... not meaningful here
break;
*/
}
}
//return (hasParentNodeSet) ? parsedNodeSet[node.tagName] : parsedNodeSet;
//if(parsedNodeSet.tagName)dojo.debug("parseElement: RETURNING NODE WITH TAGNAME "+parsedNodeSet.tagName);
return parsedNodeSet;
};
/* parses a set of attributes on a node into an object tree */
this.parseAttributes = function(/*DomNode*/node){
// summary:
// creates an attribute object that maps attribute values for the
// passed node. Note that this is similar to creating a JSON
// representation of a DOM node.
// usage:
// a node with the following serialization:
// <div foo="bar" baz="thud">...</div>
// would yeild the following return structure when passed into this
// function:
// {
// "foo": {
// "value": "bar"
// },
// "baz": {
// "value": "thud"
// }
// }
//
var parsedAttributeSet = {};
var atts = node.attributes;
// TODO: should we allow for duplicate attributes at this point...
// would any of the relevant dom implementations even allow this?
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;
};
};

View File

@@ -0,0 +1,249 @@
/*
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(/*String*/xsltUri){
// summary:
// dojo.xml.XslTransform is a convenience object that takes the URI
// String of an XSL file as a constructor argument. After each
// transformation all parameters will be cleared. Transformation is
// supported by IE, Mozilla, and partially by Opera. Other browsers
// (notably Safari) have not yet exposed their transformation
// primtives well enough to be useful.
// xsltUri:
// Url of the xslt document to transform nodes with. Transformation is
// acheived with the transformTo* methods on instances of this class.
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( /*XMLDocument*/xmlDoc,
/*2 Dimensional Array*/params,
/*HTMLDocument*/parentDoc){
// summary:
// transform the xmlDoc and return the result as a string.
// xmlDoc: an XML Document to transform
// params:
// a set of configuration parameters to pass to the transformation
// engine.
// parentDoc: The HTML docuemnt to transform the subdocument "under"
var content = null;
if(IS_IE){
addIeParams(params);
content = getIeResultStr(xmlDoc, params);
removeIeParams(params);
}else{
content = getMozillaResultStr(xmlDoc, params, parentDoc);
}
//dojo.debug(content);
return content;
};
this.transformToContentPane = function( /*XMLDocument*/xmlDoc,
/*2 Dimensional Array*/params,
/*ContentPane*/contentPane,
/*HTMLDocument*/parentDoc){
// summary:
// transform the xmlDoc and put the result into the passed
// ContentPane instance
// xmlDoc: an XML Document to transform
// params:
// a set of configuration parameters to pass to the transformation
// engine.
// contentPane:
// instance of dojo.widget.ContentPane to assign the transform
// results to
// parentDoc: The HTML docuemnt to transform the subdocument "under"
// FIXME: do we need this function?
var content = this.getResultString(xmlDoc, params, parentDoc);
contentPane.setContent(content);
};
this.transformToRegion = function( /*XMLDocument*/xmlDoc,
/*2 Dimensional Array*/params,
/*HTMLElement*/region,
/*HTMLDocument*/parentDoc){
// summary:
// transform the xmlDoc and put the result into the passed
// DomNode using innerHTML
// xmlDoc: an XML Document to transform
// params:
// a set of configuration parameters to pass to the transformation
// engine.
// region: node to put transform results in
// parentDoc: The HTML docuemnt to transform the subdocument "under"
try{
var content = this.getResultString(xmlDoc, params, parentDoc);
region.innerHTML = content;
}catch (e){
dojo.raise(e.message + "\n\n xsltUri: " + xsltUri)
}
};
this.transformToDocument = function( /*XMLDocument*/ xmlDoc,
/*2 Dimensional Array*/params){
// summary:
// transform the xmlDoc and return a new XML document containing
// the result
// xmlDoc: an XML Document to transform
// params:
// a set of configuration parameters to pass to the transformation
// engine.
return getResultDom(xmlDoc, params); // XMLDocument
}
this.transformToWindow = function( /*XMLDocument*/ xmlDoc,
/*2 Dimensional Array*/params,
/*HTMLDocument*/windowDoc,
/*HTMLDocument*/parentDoc){
// summary:
// transform the xmlDoc and put the contents in the passed
// windowDoc, blowing away any previous contents.
// xmlDoc: an XML Document to transform
// params:
// a set of configuration parameters to pass to the transformation
// engine.
// windowDoc: the HTMLDocument to assign the contents to
// parentDoc: The HTML docuemnt to transform the subdocument "under"
try{
windowDoc.open();
windowDoc.write(this.getResultString(xmlDoc, params, parentDoc));
windowDoc.close();
}catch(e){
dojo.raise(e.message + "\n\n xsltUri: " + xsltUri)
}
};
};

View File

@@ -0,0 +1,17 @@
/*
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.*");