Given your informations, I took XQilla 2.1.1, Xerces 2.8 and compiled a modified xqilla_cmd project so that it executes:

         Janitor<XMLFormatTarget> target(0);
         target.reset(new MemBufFormatTarget(1024));

EventSerializer writer("UTF-8", "1.1", target.get(), dynamic_context->getMemoryManager());
         writer.addNewlines(true);
NSFixupFilter nsfilter(&writer, dynamic_context->getMemoryManager());
         (*it2)->execute(&nsfilter, dynamic_context.get());

string result((char*)((MemBufFormatTarget*)target.get())->getRawBuffer(),
           ((MemBufFormatTarget*)target.get())->getLen()*sizeof(XMLByte));
         cout <<  result << endl;

I wrote this XQuery in order to obtain the same output you listed:

for $i in (1 to 2)
return
<b>
{attribute {concat('b', $i, 'n')} {concat('b',$i)}}
     some b{$i} text
</b>

But I got the expected

<b b1n="b1">
     some b1 text
</b>
<b b2n="b2">
     some b2 text
</b>

What is the query you are running?

Alberto


[EMAIL PROTECTED] wrote:
hi Alberto

I do not fill it. XQilla do it somehow in the writer Object:

 memtarget = new MemBufFormatTarget(0,dynamic_context->getMemoryManager());
EventSerializer writer("UTF-8", "1.1", memtarget, dynamic_context->getMemoryManager());
 writer.addNewlines(true);
 NSFixupFilter nsfilter(&writer, dynamic_context->getMemoryManager());
 query->execute(&nsfilter, dynamic_context.get());    //XQQuery

sorry for not explaining every object. I guess the filling happens in 
EventSerializer ('writer' object in my code respectively), i found the 
constructor in the source of xqilla:

EventSerializer::EventSerializer(char *encoding, char *xmlVersion, XMLFormatTarget *target, MemoryManager *mm) : formatter_(encoding, xmlVersion, target, XMLFormatter::CharEscapes, XMLFormatter::UnRep_CharRef, mm),
    elementStarted_(false),
    level_(0),
    addNewlines_(false)
 {
 }

formatter is defined as:
 XERCES_CPP_NAMESPACE_QUALIFIER XMLFormatter formatter_;
The filling happens, i guess over this method:

 void EventSerializer::piEvent(const XMLCh *target, const XMLCh *value)
 {
   formatter_ << XMLFormatter::NoEscapes << XMLFormatter::UnRep_Fail;

   if(elementStarted_) {
     elementStarted_ = false;
     formatter_ << elem_end;
   }

  formatter_ << pi_start;
  formatter_ << target;
  formatter_ << space;
  formatter_ << value;
  formatter_ << pi_end;

  if(addNewlines_ && level_ == 0) {
    formatter_ << newline;
   }
 }



greetings
  Affe


-------- Original-Nachricht --------
Datum: Wed, 09 Apr 2008 10:20:19 +0200


Von: Alberto Massari <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: MemBufFormatTarget possible bug

Affe,
could you show us how are you filling the MemBufFormatTarget?

Alberto

[EMAIL PROTECTED] wrote:
There are still problems with the Constructor initializing. The Buffer
seems not dependent on the length i am initializing.
I am working with XQilla libraries on top of Xercesc. When i initialize
the Constructor with the memory manager and with 0 length, then it
functions (hopefully stable now, the buffer is ok for different queries). But i 
do
not know why there is corrupt buffer if  the length is big like 1024 or
without the second parameter MemoryManager. Maybe someone has the same
problem.
memtarget = new
MemBufFormatTarget(0,dynamic_context->getMemoryManager());
greetings
  Affe



Reply via email to