/**
 * solseitXMLLib.js
 *
 *
 * @version 0.5 20040924
 * @author andi r.
 * @copyright Top 21 GmbH
 *
 */

/**
 * public Class solseitXMLObject
 * Container-Object für xml
 * wird erzeugt ueber die Methoden editor.createXMLObjectFromFile
 * und createXMLObjectFromString
 *
 * @author andi r.
 * @version 20040709
 *
 */

function solseitXMLObject(xmlObj)
{
   this.internalDomObject = Sarissa.getDomDocument();
   if(xmlObj.nodeType == 1)
   {
      // sehr haesslich - aber es tut vorerst!!!
      if (_SARISSA_IS_MOZ)
         this.internalDomObject._sarissa_copyDOM(xmlObj);
      else
         this.internalDomObject.documentElement = xmlObj;
   }
   else
   {
      this.internalDomObject = xmlObj;
   }
}
/**
 * private solseitXMLObj.selectNodes
 * Liefert das Ergebnis einer xPath-Abfrage auf ein solseitXMLObject
 *
 * @argument xPath (string xPath)
 * @returns (Dom-Element)
 *
 * @author: andi r.
 * @version: 20040924
 *
 */

solseitXMLObject.prototype.selectNodes = function(xPath)
{
   return this.internalDomObject.selectNodes(xPath);
}
/**
 * public boolean solseitXMLObject.addAttributeByXPath
 * erzeugt/aendert ein Attribut
 *
 * @argument xPath (string xPath)
 * @argument attName (string Attributename)
 * @argument val (string Attributevalue)
 * @returns boolean
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.addAttributeByXPath = function(xPath, attName, attVal)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      try
      {
         objNodeList.item(0).setAttribute(attName, attVal);
         return true;
      }
      catch(e)
      {
         new solseitError("solseitXMLObject.addAttributeByXPath", 1003, "_js/solseit/solseitXMLLib.js", e);
         return false;
         // Attribut konnte nicht erzeugt werden
      }
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.addAttributeByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      return false;
      // mehr als 1 Ergebnis
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.addAttributeByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
      // kein Ergebnis
   }
   else
   {
      new solseitError("solseitXMLObject.addAttributeByXPath", 0, "_js/solseit/solseitXMLLib.js");
      return false;
      // sonstiger Fehler
   }
}
/**
 * public boolean solseitXMLObject.addElementBeforeXPath
 *
 *
 * @argument xPath (string xPath)
 * @argument xmlObj (object solseitXMLObject)
 *
 * @author andi r.
 * @version 20040710
 *
 */

solseitXMLObject.prototype.addElementBeforeByXPath = function(xPath, xmlObj)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      try
      {
         var act = objNodeList.item(0);
         act.parentNode.insertBefore(xmlObj.internalDomObject, act);
      }
      catch(e)
      {
         new solseitError("solseitXMLObject.addElementBeforeByXPath", 1004, "_js/solseit/solseitXMLLib.js", e);
         return false;
         // Element konnte nicht eingefügt werden
      }
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.addElementBeforeByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      return false;
      // mehr als 1 Ergebnis
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.addElementBeforeByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
      // kein Ergebnis
   }
   else
   {
      new solseitError("solseitXMLObject.addElementBeforeByXPath", 0, "_js/solseit/solseitXMLLib.js");
      return false;
      // sonstiger Fehler
   }
}
/**
 * public boolean solseitXMLObject.addElementByXPath
 *
 * @argument xPath (string xPath)
 * @argument xmlObj (object solseitXMLObject)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.addElementByXPath = function(xPath, xmlObj)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      try
      {
         var act = objNodeList.item(0);
         if(xmlObj.internalDomObject.nodeType == 9)
         {
            act.appendChild(xmlObj.getDocumentElement());
         }
         else
         {
            act.appendChild(xmlObj.internalDomObject);
         }
      }
      catch(e)
      {
         new solseitError("solseitXMLObject.addElementByXPath", 1004, "_js/solseit/solseitXMLLib.js", e);
         return false;
         // Element konnte nicht eingefügt werden
      }
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.addElementByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      return false;
      // mehr als 1 Ergebnis
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.addElementByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
      // kein Ergebnis
   }
   else
   {
      new solseitError("solseitXMLObject.addElementByXPath", 0, "_js/solseit/solseitXMLLib.js");
      return false;
      // sonstiger Fehler
   }
}
/**
 * public boolean solseitXMLObject.checkXPath
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.checkXPath = function(xPath)
{
   objNodeList = this.selectNodes(xPath);
   if(objNodeList.length > 0)
   {
      return true;
   }
   else
   {
      return false;
   }
}
/**
 * public element solseitXMLObject.getDocumentElement
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.getDocumentElement = function()
{
   return this.internalDomObject.documentElement;
}
/**
 * public domElement solseitXMLObject.getElementByXPath
 *
 * @argument xPath (string xPath)
 * @return (object domElement)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.getElementByXPath = function(xPath)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      var act = objNodeList.item(0);
      var copied = act.cloneNode(true);
      return copied;
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.getElementByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      return false;
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.getElementByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
   }
}
/**
 * public domElement solseitXMLObject.getXMLObjectByXPath
 *
 * @argument xPath (string xPath)
 * @return (object solseitXMLObject)
 *
 * @author andi r
 * @version 20040804
 *
 */

solseitXMLObject.prototype.getXMLObjectByXPath = function(xPath)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      var act = objNodeList.item(0);
      var copied = act.cloneNode(true);
      return new solseitXMLObject(copied);
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.getXMLObjectByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      return false;
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.getXMLObjectByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
   }
}
/**
 * public string solseitXMLObject.getValueByXPath
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.getValueByXPath = function(xPath)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      if(objNodeList.item(0).childNodes.length && objNodeList.item(0).firstChild.nodeType == 3)
      {
         return objNodeList.item(0).firstChild.nodeValue;
      }
      else
      {
         return new String();
      }
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.getValueByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      return false;
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.getValueByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
   }
}
/**
 * public array solseitXMLObject.getValueByXPath
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.getValuesByXPath = function(xPath)
{
   var returnArray = new Array();
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l >= 1)
   {
      try{
         for(var i = 0; i < l; i++)
         {
            if(objNodeList.item(i).childNodes.length && objNodeList.item(i).firstChild.nodeType == 3)
            {
               returnArray.push(objNodeList.item(i).firstChild.nodeValue);
            }
            else
            {
               returnArray.push('');
            }
         }
         return returnArray;
      }
      catch(e)
      {
         new solseitError("solseitXMLObject.getValuesByXPath", 0, "_js/solseit/solseitXMLLib.js", e);
      }
   }
   else
   {
      new solseitError("solseitXMLObject.getValuesByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      return false;
   }
}

/**
 * public solseitXMLCollection solseitXMLObject.getXMLCollectionByXPath
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.getXMLCollectionByXPath = function(xPath)
{
   try{
      var collection = new solseitXMLCollection();
      var objNodeList = this.selectNodes(xPath);
      var l = objNodeList.length;
      if(l > 0)
      {
         for(var i = 0; i < l; i++)
         {
         	var o = new solseitXMLObject(objNodeList.item(i).cloneNode(true));
            collection.add(o);
         }
         return collection;
      }
      else
      	return new solseitXMLCollection();
      /*{
         new solseitError("solseitXMLObject.getXMLCollectionByXPath", 1002, "_js/solseit/solseitXMLLib.js");
         return false;
      }*/
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.getXMLCollectionByXPath", 1101, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}
/**
 * public boolean solseitXMLObject.removeAllByXPath
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.removeAllByXPath = function(xPath)
{
   try{
      var objNodeList = this.selectNodes(xPath);
      var l = objNodeList.length;
      if(l > 0)
      {
         for(var i = 0; i < l; i++)
         {
            objNodeList.item(i).parentNode.removeChild(objNodeList.item(i));
         }
         return true;
      }
      else
      {
         new solseitError("solseitXMLObject.removeAllByXPath", 1002, "_js/solseit/solseitXMLLib.js");
         return false;
      }
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.removeAllByXPath", 1005, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}
/**
 * public boolean solseitXMLObject.removeByXPath
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.removeByXPath = function(xPath)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      objNodeList.item(0).parentNode.removeChild(objNodeList.item(0));
      return true;
   }
   else if(l < 1)
   {
      new solseitError('solseitXMLObject.removeByXPath', 1002, "_js/solseit/solseitXMLLib.js");
      return false;
   }
   else if(l > 1)
   {
      new solseitError('solseitXMLObject.removeByXPath', 1001, "_js/solseit/solseitXMLLib.js");
      return false;
   }
   else
   {
      new solseitError('solseitXMLObject.removeByXPath', 0, "_js/solseit/solseitXMLLib.js");
      return false;
   }
}
/**
 * public boolean solseitXMLObject.replaceElementByXPath
 *
 * @argument xPath (string xPath)
 * @argument xmlObj (object solseitXMLObject)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.replaceElementByXPath = function(xPath, xmlObj)
{
   try{
      var objNodeList = this.selectNodes(xPath);
      var l = objNodeList.length;
      if(l == 1)
      {
         objNodeList.item(0).parentNode.replaceChild(xmlObj.getDocumentElement(), objNodeList.item(0));
         return true;
      }
      else if(l < 1)
      {
         new solseitError('solseitXMLObject.replaceElementByXPath', 1002, "_js/solseit/solseitXMLLib.js");
         return false;
      }
      else if(l > 1)
      {
         new solseitError('solseitXMLObject.replaceElementByXPath', 1001, "_js/solseit/solseitXMLLib.js");
         return false;
      }
      else
      {
         new solseitError('solseitXMLObject.replaceElementByXPath', 0, "_js/solseit/solseitXMLLib.js");
         return false;
      }
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.removeAllByXPath", 1006, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}
/**
 * public boolean solseitXMLObject.setValueByXPath
 *
 * @argument xPath (string xPath)
 * @argument val (string Elementvalue)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLObject.prototype.setValueByXPath = function(xPath, val)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   if(l == 1)
   {
      try
      {
         var actItem = objNodeList.item(0);
         var actType = actItem.nodeType;
         if(actType == 1)
         {
            // node
            if(actItem.hasChildNodes())
            {
               actItem.firstChild.nodeValue = val;
               return true;
            }
            else
            {
               // keine ChildNodes -> textnode erzeugen und anh\u00e4ngen
               newTextNode = this.internalDomObject.createTextNode(val);
               actItem.appendChild(newTextNode);
               return true;
            }
         }
         else if(actType == 2)
         {
            // attribute
            var n = actItem.nodeName;
            actItem.nodeValue = val;
            return true;
         }
      }
      catch(e)
      {
         new solseitError("solseitXMLObject.setValueByXPath", 1007, "_js/solseit/solseitXMLLib.js", e);
         // Node konnte nicht erzeugt werden
         return false;
      }
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.setValueByXPath", 1001, "_js/solseit/solseitXMLLib.js");
      // mehr als 1 Ergebnis
      return false;
   }
   else if(l < 1)
   {
      new solseitError("solseitXMLObject.setValueByXPath", 1002, "_js/solseit/solseitXMLLib.js");
      // kein Ergebnis
      return false;
   }
   else
   {
      new solseitError("solseitXMLObject.setValueByXPath", 0, "_js/solseit/solseitXMLLib.js");
      // sonstiger Fehler
      return false;
   }
}
/**
 * public void solseitXMLObject.moveByXPath
 *
 * verschiebt einen Node innerhalb des Baumes
 * 26.05.2004: Workaround wegen Problemen in Mozilla: Mozilla erkennt whitespace (linefeeds etc.)
 * als node und wertet sie mit, IE aber nicht. Daher wird mit den Methoden node_before()
 * und node_after() gearbeitet. Diese bereinigen diese Whitespace-text-nodes
 *
 * @argument XPath (string xPath)
 * @argument direction (string) up oder down gibt die Verschieberichtung an
 * @exception Fehler im XPath
 *
 * @author andi r.
 * @version 20040803
 *
 */

solseitXMLObject.prototype.moveByXPath = function(xPath, direction)
{
   var objNodeList = this.selectNodes(xPath);
   var l = objNodeList.length;
   var bFound = false;
   if(l == 1)
   {
      var node = objNodeList.item(0);
      var nodeParent = node.parentNode;
      //var tmpNode = nodeCleaner( node.cloneNode( true ) );
      tmpNode = node.cloneNode(true);
      if(direction == 'up' && node_before(node))
      {
         // verschieben nach oben
         nodeParent.insertBefore(tmpNode, node_before(node));
         bFound = true;
      }
      else if(direction == 'down')
      {
         // verschieben nach unten
         if(node_after(node_after(node)))
         {
            var nextNode = node_after(node);
            nodeParent.insertBefore(tmpNode, node_after(nextNode));
            bFound = true;
         }
         else if(node_after(node))
         {
            nodeParent.appendChild(tmpNode);
            bFound = true;
         }
      }
      if(bFound)
      {
         nodeParent.removeChild(node);
      }
   }
   else if(l > 1)
   {
      new solseitError("solseitXMLObject.moveByXPath", 1001, "_js/solseit/solseitXMLLib.js");
   }
   else if(l < 1)
   {
            new solseitError("solseitXMLObject.setValueByXPath", 1002, "_js/solseit/solseitXMLLib.js");
   }
}

/**
 * public solseitXMLObject solseitXMLObject.cleanCopyNode
 *
 * entfernt aus einem Node alle werte mit hilfe der fkt. nodeCleaner
 *
 * @argument depth (boolean) gibt an, ob nur der aktuelle node verwendet
 * werden soll oder auch seine ChildNodes
 * @exception XPath ergibt kein Ergebnis oder nicht eindeutig
 * @return solseitXMLObject
 *
 * @author andi r.
 * @version 20040803
 *
 */

solseitXMLObject.prototype.cleanCopyNode = function(xPath, depth)
{
   var oNode = this.getElementByXPath(xPath);
   var node = oNode.cloneNode(depth);


   // eigentliche Bereinigung aufrufen
   result = nodeCleaner(node);
   ret = new solseitXMLObject(result);
   return ret;
}
/**
 * public void solseitXMLObject.appendCleanCopyNode
 *
 * @argument xPath (string xPath)
 * @argument depth (boolean)
 *
 * @author andi r.
 * @version 20040804
 *
 */

solseitXMLObject.prototype.appendCleanCopyNode = function(xPath, depth)
{
   orig = this.internalDomObject.selectNodes(xPath).item(0);
   copy = this.cleanCopyNode(xPath, true);
   copyElem = copy.internalDomObject;
   if(node_after(orig))
   {
      orig.parentNode.insertBefore(copyElem.documentElement, node_after(orig));
   }
   else
   {
      orig.parentNode.appendChild(copyElem.documentElement);
   }
}
/**
 * public string solseitXMLObject.toString
 *
 * @author andi r
 * @version 20040709
 *
 */
solseitXMLObject.prototype.toString = function()
{
   try
   {
      return this.internalDomObject.xml;
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.toString", 1008, "_js/solseit/solseitXMLLib.js", e);
   }
}

/**
 * public string solseitXMLObject.xslTransform
 *
 * @argument xslObj (object solseitXMLObject)
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLObject.prototype.xslTransform = function(xslObj)
{
   var transformed = new String();
   try
   {
      var transformed = this.internalDomObject.transformNode(xslObj.internalDomObject);
      return transformed;
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.xslTransform", 1009, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}


/**
 * public string solseitXMLObject.showInlineTree
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLObject.prototype.showInlineTree = function()
{
   try
   {
      return createXmlTree(this.internalDomObject, 0);
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.showInlineTree", 1010, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public string solseitXMLObject.showInlineHtml
 *
 * @argument xslObj (object solseitXMLObject)
 * @return (string)
 *
 * @author andi r.
 * @version 20040727
 *
 */

solseitXMLObject.prototype.showInlineHtml = function(xslObj)
{
   try
   {
      return showInlineHtml(this.internalDomObject, xslObj.internalDomObject);
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.showInlineHtml", 1010, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * private boolean solseitXMLObject.setXslParameter
 *
 * abgeleitetet / angepasste Funktion aus der Sarissa-Library
 * setzt im gesamten xsl-Dokument, das aufgerufen wird den entsprechenden
 * wert in die xsl-Params, sofern diese vorhanden sind. Das Original hatte
 * nach dem ersten xsl:param, der gefunden wurde, das setzen abgebrochen.
 *
 * @argument sParamQName Name des xsl:param
 * @argument sParamValue Value  -||-
 * @return boolean erfolgreich oder nicht
 *
 * @author andi r.
 * @version 20040729
 *
 */

solseitXMLObject.prototype.setXslParameter = function(sParamQName, sParamValue)
{
   try
   {
      var params = this.internalDomObject.getElementsByTagName(_SARISSA_IEPREFIX4XSLPARAM + "param");
      var iLength = params.length;
      var bFound = false;
      var param;
      if(sParamValue)
      {
         for(i = 0; i < iLength; i++)
         {
            // alt: for(i=0; i < iLength && !bFound;i++){
            // match a param name attribute with the name given as argument
            if(params[i].getAttribute("name") == sParamQName)
            {
               param = params[i];
               // clean up the parameter
               while(param.firstChild)
               {
                  param.removeChild(param.firstChild);
               }
               if(!sParamValue || sParamValue == null)
               {
                  // do nothing; we've cleaned up the parameter anyway
               }
               // if String
               else if( typeof sParamValue == "string")
               {
                  param.setAttribute("select", sParamValue);
                  bFound = true;
               }
               // if node
               else if(sParamValue.nodeName)
               {
                  param.removeAttribute("select");
                  param.appendChild(sParamValue.cloneNode(true));
                  bFound = true;
               }
               // if NodeList
               else if(sParamValue.item(0) && sParamValue.item(0).nodeType)
               {
                  for(j = 0; j < sParamValue.length; j++)
                  {
                     if(sParamValue.item(j).nodeType)
                     {
                        // check if this is a Node
                        param.appendChild(sParamValue.item(j).cloneNode(true));
                     }
                  }
                  bFound = true;
               }
               // if Array or IE's IXMLDOMNodeList
               else
               {
                  new solseitError("solseitXMLObject.setXslParameter", 1011, "_js/solseit/solseitXMLLib.js", e);
               }
            }
         }
      }
      return bFound;
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.setXslParameter", 1011, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}

/**
 * public Class solseitXMLCollection
 *
 * @author andi r
 * @version 20040710
 *
 */

function solseitXMLCollection()
{
   try
   {
      var oDomDoc = Sarissa.getDomDocument();
      oDomDoc.setProperty("SelectionNamespaces", getClientNamespaces());
      oDomDoc.loadXML('<solseit:collection ' + getClientNamespaces() + '/>');
      this.internalCollection = oDomDoc;
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection", 1101, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public void solseitXMLCollection.add
 *
 * @argument xmlObj (object solseitXMLObj)
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.add = function(xmlObj)
{
   try
   {
      if(xmlObj.internalDomObject.nodeType == 1)
      {
         this.internalCollection.documentElement.appendChild(xmlObj.internalDomObject);
      }
      else if(xmlObj.internalDomObject.nodeType == 9)
      {
         this.internalCollection.documentElement.appendChild(xmlObj.internalDomObject.documentElement);
      }
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.add", 1102, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public solseitXMLObject solseitCollection.getCollectionXMLObject
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.getCollectionXMLObject = function()
{
   return new solseitXMLObject(this.internalCollection);
}

/**
 * public Element solseitXMLCollection.getItemAsElement
 *
 * @argument index (int index)
 *
 * @author andi r
 * @version 20040710
 *
 */

solseitXMLCollection.prototype.getItemAsElement = function(index)
{
   try
   {
      return this.internalCollection.documentElement.childNodes[index];
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.getItemAsElement", 1103, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public solseitXMLObject solseitXMLCollection.getItemAsNewXMLObject
 *
 * @argument index (int index)
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.getItemAsNewXMLObject = function(index)
{
   if(index < this.getSize() && index >= 0)
   {
      return new solseitXMLObject(this.internalCollection.documentElement.childNodes[index]);
   }
   else
   {
      new solseitError("solseitXMLCollection.getItemAsNewXMLObject", 1103, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}
/**
 * public Integer solseitXMLCollection.getSize
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.getSize = function()
{
   try
   {
      return this.internalCollection.documentElement.childNodes.length;
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.getSize", 0, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public boolean solseitXMLCollection.isEmpty
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.isEmpty = function()
{
   try
   {
      return !this.internalCollection.documentElement.hasChildNodes();
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.isEmpty", 0, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}
/**
 * public Iterator solseitXMLCollection.iterator
 *
 * @argument xPath (string xPath)
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.iterator = function(xPath)
{
   try
   {
      return new Iterator(this.internalCollection.documentElement.childNodes);
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.iterator", 1104, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public void solseitXMLCollection.removeElement
 *
 * @argument index (int index)
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.removeElement = function(index)
{
   if(index < this.getSize())
   {
      this.internalCollection.documentElement.removeChild(this.internalCollection.documentElement.childNodes[index]);
   }
   else
   {
      new solseitError("solseitXMLCollection.removeElment", 1105, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public string solseitXMLCollection.toString
 *
 * @author andi r
 * @version 20040710
 *
 */
solseitXMLCollection.prototype.toString = function()
{
   try
   {
      return this.internalCollection.xml;
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.toString", 1106, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public object solseitXMLCollection.xslTransform
 *
 * @argument xslObj (object solseitXMLObject)
 * @argument result (??)
 *
 * @author andi r
 * @version 20040727
 *
 */
solseitXMLCollection.prototype.xslTransform = function(xslDoc, result)
{
   var transformed = new String();
   try
   {
      var transformed = this.internalDomObject.transformNode(xslObj.internalDomObject);
      return transformed;
   }
   catch(e)
   {
      new solseitError("solseitXMLCollection.xslTransform", 1107, "_js/solseit/solseitXMLLib.js", e);
      return false;
   }
}
/**
 * public boolean solseitXMLCollection.setXSLParameter
 *
 * @argument sParamQName (string)
 * @argument sParamValue (string)
 * @return (boolean)
 *
 * @author andi r.
 * @version 20040728
 *
 */

solseitXMLCollection.prototype.setXSLParameter = function(sParamQName, sParamValue)
{
   this.setXSLParameter(sParamQName, sParamValue);
}
/**
 * public string solseitXMLCollection.showInlineTree
 *
 * @author andi r
 * @version 20040727
 *
 */

solseitXMLCollection.prototype.showInlineTree = function()
{
   try
   {
      return createXmlTree(this.internalCollection, 0);
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.showInlineTree", 1010, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * public string solseitXMLObject.showInlineHtml
 *
 * @argument xslObj (object solseitXMLObject)
 * @return (string)
 *
 * @author andi r.
 * @version 20040727
 *
 */

solseitXMLCollection.prototype.showInlineHtml = function(xslObj)
{
   try
   {
      return showInlineHtml(this.internalCollection, xslObj.internalCollection);
   }
   catch(e)
   {
      new solseitError("solseitXMLObject.showInlineHTML", 1011, "_js/solseit/solseitXMLLib.js", e);
   }
}
/**
 * private Class Iterator
 *
 * @argument it (nodeList) nodelist, aus der der Iterator gebaut wird
 *
 * @author andi r.
 * @version 20040709
 *
 */

function Iterator(it)
{
   this.internalIterator = it;
   this.pointer = 0;
}
/**
 * private boolean Iterator.hasNext
 *
 * @author andi r
 * @version 20040709
 *
 */
Iterator.prototype.hasNext = function()
{
   return(this.pointer < this.getLength());
}
/**
 * private boolean Iterator.hasPrevious
 *
 * @author andi r
 * @version 20040709
 *
 */
Iterator.prototype.hasPrevious = function()
{
   return(this.pointer > 0);
}
/**
 * private solseitXMLObject Iterator.next
 *
 * @author andi r
 * @version 20040709
 *
 */
Iterator.prototype.next = function()
{
	var ret = this.internalIterator.item(this.pointer);
   
   if(ret.nodeType != 'undefined')
   {
      switch(ret.nodeType)
      {
         case 1 :
            {
               ret = new solseitXMLObject(ret);
               break;
            }
         case 3 :
            {
               ret = ret.xml;
               break
            }
         default :
            {
               new solseitError("iterator.next", 1202, "_js/solseit/solseitXMLLib.js", e);
               break;
            }
      }
   }
   else
   {
      new solseitError("iterator.next", 1201, "_js/solseit/solseitXMLLib.js", e);
   }
   
   return ret;
}
/**
 * private solseitXMLObject Iterator.previous
 *
 * @author andi r
 * @version 20040709
 *
 */
Iterator.prototype.previous = function()
{
   this.pointer--;
   var ret = this.internalIterator.item(this.pointer);
   if(ret.nodeType != 'undefined')
   {
      switch(ret.nodeType)
      {
         case 1 :
            {
               ret = new solseitXMLObject(ret);
               break;
            }
         case 3 :
            {
               ret = ret.xml;
               break;
            }
         default :
            {
               new solseitError("iterator.previous", 1202, "_js/solseit/solseitXMLLib.js", e);
               break;
            }
      }
   }
    else
   {
      new solseitError("iterator.previous", 1201, "_js/solseit/solseitXMLLib.js", e);
   }
   return ret;
}
/**
 * private Integer Iterator.getLength
 *
 * @author andi r
 * @version 20040709
 *
 */
Iterator.prototype.getLength = function()
{
   return this.internalIterator.length;
}
