comete_blog

Archive for janvier, 2010

Problem in implementation

by admin on jan.18, 2010, under Non classé

Last week I talk took Dabid Humphrey.

I wanted to ask him if we could just implement some public members in the javascript class.
I asked this after having taking a look at the XmlElement.java.

Me and RaphKun saw that the implemented class did not match with the interface define in documentation.

So after discussing with David we agreed that the javascript implementation should follow the java implementation.

The problem is that now we have to reimplement what we did.
But this time we know how to implement a javascript object class. Wich was the ardest part for me ^^.

Leave a Comment more...

Version 0.1

by admin on jan.04, 2010, under Non classé

There is the 0.1 version.


//XMLElement constructor
function XMLElement(parent, file){
// The parent of the XMLELement
this.parent = parent;
// The file of the XMLELement
this.file = file;
// The XML document
this.xmlDoc = null;
// The ChildNodes of The XML Elements
this.childNodes = null;
// The name of the XMLELement
this.name = null;
// The content of the XMLElement
this.content = null;
// The file has to be loaded for the first XMLElement only
if(file != null){
try{
this.xmlDoc = document.implementation.createDocument("","",null);
this.xmlDoc.async = false;
this.xmlDoc.load(file);
}
catch(e){
alert(e.message);
return;
}
}
//This function has for goal to avoïd the text element in child Nodes. Only Node Element are managed
function getFilteredChildNodes(childNodes){
var result = new Array();
for(var i = 0; i < childNodes.length; i ++){
if(childNodes[i].nodeType == 1 ){
result[i] = childNodes[i];
}
}
return result;
};
//This function creates is used by methods getChild(), and getChildren()
function createXMLElement(childNode){
var result = new XMLElement(this, this.file);
result.xmlDoc = this.xmlDoc;
// On creation ChildNodes are always filtered
result.childNodes = getFilteredChildNodes(childNode.childNodes);
result.name = childNode.nodeName;
return result;
};
//This function has for goal to check that the given index is correct for a childNodeArray
function checkIndexValidity(childNodes, index){
if(index >= childNodes.length || index < 0){
throw "The given index is not valid and is not between 0 and childNodes.length";
}
};
//Check if the childNodes attribute is null, if it is null it means that the current element is the root element.
// So the array must be filtered.
function getFilteredChildNodes(childNodes, xmlDoc){
if(childNodes == null){
return getFilteredChildNodes(xmlDoc.childNodes);
}else{
return childNodes;
}
};
//This method must return the number of children of the element
this.getChildCount = function getChildCount(){
return getFilteredChildNodes(this.childNodes, this.xmlDoc).length;
};
//This method must return the child at the given index.
this.getChild = function getChild(index){
var child = getFilteredChildNodes(this.childNodes, this.xmlDoc)[index];
var result = createXMLElement(child);
return result;
};
// Returns all of the children as an XMLElement array
this.getChildren = function getChildren(){
var result = new Array();
var childNodesArray = getFilteredChildNodes(this.childNodes, this.xmlDoc);
for(var i = 0; i < childNodesArray.length; i ++){
var child = createXMLElement(childNodesArray[i]);
result.push(child);
}
return result;
}
// Returns the content of the element
this.getContent = function getContent(){

}
};

function setup(){
var xmlElement = new XMLElement(this, "sites.xml");
var childCount = xmlElement.getChildCount();
var childName = xmlElement.getChild(0).getChild(1).name;
var children = xmlElement.getChild(0).getChildren();
var stop;
};
setup();

///////////////////*************************************************************************
function Personne(){
this.call = function call(){
alert("yo");
};
};
var personne = new Personne();
personne.call();
///////////////////*************************************************************************
Leave a Comment more...

by admin on jan.03, 2010, under Non classé

There is the new version of the xmlElement. This time oriented object javascript has been really used.

There are actually 3 methods that miss :


//XMLElement constructor
function XMLElement(parent, file){
// The parent of the XMLELement
this.parent = parent;
// The file of the XMLELement
this.file = file;
// The XML document
this.xmlDoc = null;
// The ChildNodes of The XML Elements
this.childNodes = null;
// The name of the XMLELement
this.name = null;
// The file has to be loaded for the first XMLElement only
if(file != null){
try{
this.xmlDoc = document.implementation.createDocument("","",null);
this.xmlDoc.async = false;
this.xmlDoc.load(file);
}
catch(e){
alert(e.message);
return;
}
}
//This function has for goal to avoïd the text element in child Nodes. Only Node Element are managed
function getFilteredChildNodes(childNodes){
var result = new Array();
for(var i = 0; i < childNodes.length; i ++){
if(childNodes[i].nodeType == 1 ){
result[i] = childNodes[i];
}
if(childNodes[i].nodeType == 3 ){
this.content = childNodes[i];
}
}
return result;
};
//This function has for goal to check that the given index is correct for a childNodeArray
function checkIndexValidity(childNodes, index){
if(index >= childNodes.length || index < 0){
throw "The given index is not valid and is not between 0 and childNodes.length";
}
};
//Check if the childNodes attribute is null, if it is null it means that the current element is the root element.
// So the array must be filtered.
function getFilteredChildNodes(childNodes, xmlDoc){
if(childNodes == null){
return getFilteredChildNodes(xmlDoc.childNodes);
}else{
return childNodes;
}
};
//This method must return the number of children of the element
this.getChildCount = function getChildCount(){
return getFilteredChildNodes(this.childNodes, this.xmlDoc).length;
};
//This method must return the child at the given index.
this.getChild = function getChild(index){
var result = new XMLElement(this, file);
var kidNode = getFilteredChildNodes(this.childNodes, this.xmlDoc)[index];
result.xmlDoc = this.xmlDoc;
// On creation ChildNodes are always filtered
result.childNodes = getFilteredChildNodes(kidNode.childNodes);
result.name = kidNode.nodeName;
return result;
};
// Returns all of the children as an XMLElement array
this.getChildren = function getChildren(){
var result = new Array();
var childNodesArray = getFilteredChildNodes(this.childNodes, this.xmlDoc);
for(var i = 0; i < childNodesArray.length; i ++){
var child = new XMLElement(this, file);
child.xmlDoc = this.xmlDoc;
// On creation ChildNodes are always filtered
child.childNodes = getFilteredChildNodes(childNodesArray[i].childNodes);
child.name = childNodesArray[i].nodeName;
result.push(child);
}
return result;
}
// Returns the content of the element
this.getContent = function getContent(){

}
};
this.setup = function setup(){
var xmlElement = new XMLElement(this, "sites.xml");
var childCount = xmlElement.getChildCount();
var childName = xmlElement.getChild(0).getChild(1).name;
var children = xmlElement.getChild(0).getChildren();
var stop;
}
setup();

///////////////////*************************************************************************
function Personne(){
this.call = function call(){
alert("yo");
};
};

var personne = new Personne();
personne.call();
///////////////////*************************************************************************
Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

    Archives

    All entries, chronologically...