On Mon, 2003-09-08 at 16:09, Timothy Larson wrote: > --- Bruno Dumon <[EMAIL PROTECTED]> wrote: > ... > > I don't know what you've attempted so far, but I think the following > > will work (warning: pseudo code): > > > > XMLByteStreamCompiler comp = new XMLByteStreamCompiler(); > > String mytext = "piet snot"; > > comp.characters(mytext.toCharArray(), 0, mytext.length()); > > Object compiledSAX = comp.getSAXFragment(); > ... > > Thanks for the help. I now have two working solutions: > > function setLabel1 (widgetDefinition, labelString) { > var comp = new Packages.org.apache.cocoon.components.sax.XMLByteStreamCompiler(); > var text = new java.lang.String(labelString); > comp.characters(text.toCharArray(), 0, text.length()); > var compiledSAX = comp.getSAXFragment(); > widgetDefinition.setLabel(compiledSAX); > } > > function setLabel2 (widgetDefinition, labelString) { > var doc = new Packages.org.apache.xerces.dom.DocumentImpl(); > var elem = doc.createElementNS("http://apache.org/cocoon/woody/definition/1.0", > "label"); > var text = doc.createTextNode(labelString); > elem.appendChild(text); > var label = > Packages.org.apache.cocoon.woody.util.DomHelper.compileElementContent(elem); > widgetDefinition.setLabel(label); > } >
the first one should be way faster. > BTW: What do XMLByteStreamCompiler.writeString and friends do? That method shouldn't be used directly (and shouldn't be public probably). It's used everwhere where a string needs to be written as part of the compiled SAX events. -- Bruno Dumon http://outerthought.org/ Outerthought - Open Source, Java & XML Competence Support Center [EMAIL PROTECTED] [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]