Dear BaseXers,

So far, BaseX has been a lot of fun to work with! Thanks for all your efforts on this codebase.

i've got a couple of questions, though. 
Any help would be greatly appreciated.

Best wishes,

--greg

override def getCollection( createIfMissing : Boolean )(
    xmlCollStr : String
  ) : Option[Collection] = {
    try {
      // BUGBUG -- LGM the semantics of BXCollection a little
      // different than createIfMissing; and requires catching the
      // database not found exception
      Some( new BXCollection( xmlCollStr, true ) )
    } 
    catch {
      case e : XMLDBException => {
val bxColl = new BXCollection( xmlCollStr, false )
val document =
 bxColl.createResource(
   null, XMLResource.RESOURCE_TYPE
 ).asInstanceOf[XMLResource]

document.setContent( "<database></database>" )
bxColl.storeResource( document )
Some( bxColl )
      }
      case _ => None
    }
  }

override def update( xmlCollStr : String )(
    cnxn : CnxnCtxtLabel[Namespace,Var,String]
  ) : Unit = {   
    for( xmlColl <- getCollection( true )( xmlCollStr ) ) {
      val resourceList : Array[String] = xmlColl.listResources
      if ( resourceList.size == 0 ) {
val document =
 xmlColl.createResource(
   null, XMLResource.RESOURCE_TYPE
 ).asInstanceOf[XMLResource]

document.setContent( xmlIfier.asXML( cnxn ).toString )
xmlColl.storeResource( document )
      }
      else {
val cnxnElem = xmlIfier.asXML( cnxn )
cnxnElem match {
 case cElem : Elem => {
   delete( xmlCollStr, resourceList( 0 ) )( cElem )
   insert( xmlCollStr, resourceList( 0 ) )( cElem )
 }
 case _ => {
   throw new Exception( "record is not an XML element" )
 }
}
      }
    }
  }

<tweet>storing to db : org.basex.api.xmldb.BXDatabase@77dc754 pair : record(contactMeUsing(email), {&quot;com.biosimilarity.lift.model.store.MonadicTermTypes_-Ground&quot;:{&quot;v&quot;:{&quot;@class&quot;:&quot;string&quot;,&quot;$&quot;:&quot;for the win Mikail.Mauz@gmail.com&quot;},&quot;_-outer&quot;:{&quot;@class&quot;:&quot;com.biosimilarity.lift.model.store.PersistedMonadicTS$TheMTT$&quot;}}}) in coll : Squibble</tweet>
java.lang.IndexOutOfBoundsException
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(RandomAccessFile.java:322)
at java.io.RandomAccessFile.readFully(RandomAccessFile.java:381)
at org.basex.io.DataAccess.cursor(DataAccess.java:225)
at org.basex.io.DataAccess.readToken(DataAccess.java:147)
at org.basex.data.DiskData.txt(DiskData.java:213)
at org.basex.data.DiskData.text(DiskData.java:181)
at org.basex.api.xmldb.BXCollection.listResources(BXCollection.java:128)
at com.biosimilarity.lift.model.store.xml.BaseXCnxnStorage$$anonfun$update$1.apply(BaseXXMLPersist.scala:313)
at com.biosimilarity.lift.model.store.xml.BaseXCnxnStorage$$anonfun$update$1.apply(BaseXXMLPersist.scala:312)
at scala.Option.foreach(Option.scala:185)
at com.biosimilarity.lift.model.store.xml.BaseXCnxnStorage$class.update(BaseXXMLPersist.scala:312)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction.update(PersistedMonadicTermStore.scala:321)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction$$anonfun$putInStore$3$$anonfun$apply$12$$anonfun$apply$13.apply(PersistedMonadicTermStore.scala:468)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction$$anonfun$putInStore$3$$anonfun$apply$12$$anonfun$apply$13.apply(PersistedMonadicTermStore.scala:459)
at scala.Option.foreach(Option.scala:185)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction$$anonfun$putInStore$3$$anonfun$apply$12.apply(PersistedMonadicTermStore.scala:459)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction$$anonfun$putInStore$3$$anonfun$apply$12.apply(PersistedMonadicTermStore.scala:458)
at scala.Option.foreach(Option.scala:185)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction$$anonfun$putInStore$3.apply(PersistedMonadicTermStore.scala:458)
at com.biosimilarity.lift.model.store.PersistedTermStoreScope$PersistedMonadicGeneratorJunction$$anonfun$putInStore$3.apply(PersistedMonadicTermStore.scala:458)
at scala.util.continuations.package$.run(package.scala:30)
at scala.concurrent.cpsops$$anonfun$spawn$1.apply$mcV$sp(cpsops.scala:9)
at scala.concurrent.FJTaskRunners$FJTaskRunner$$anon$1.compute(FJTaskRunners.scala:21)
at jsr166y.forkjoin.RecursiveAction.exec(RecursiveAction.java:247)
at jsr166y.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:286)

--
L.G. Meredith
Managing Partner
Biosimilarity LLC
7329 39th Ave SW
Seattle, WA 98136

+1 206.650.3740

http://biosimilarity.blogspot.com