package org.madore.damlengine; import java.util.ArrayList; import org.w3c.dom.*; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSParser; import org.w3c.dom.ls.LSInput; public final class TodoWeblogSelectElement extends TodoDefaultElement { public static class Factory extends TodoElement.Factory { @Override public TodoWeblogSelectElement newItem(Element node, Context ctx, TodoItem caller) { return new TodoWeblogSelectElement(node, ctx, caller); } } public TodoWeblogSelectElement(Element node, Context ctx, TodoItem caller) { super(node, ctx, caller); } @Override public void handleNodeOnly() { if ( ctx.wsc == null ) { throw new IllegalStateException("weblog-select element encountered with no weblog selection state"); } final DOMImplementationLS domi = (DOMImplementationLS)ctx.doc.getImplementation(); LSParser par = domi.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null); ArrayList toProcess = new ArrayList(ctx.wsc.xmlData.size()); for ( String str : ctx.wsc.xmlData ) { LSInput input = domi.createLSInput(); input.setStringData(str); // Xerces2 does not implement parseWithContext() :-( // Node newNode = par.parseWithContext(input, node, // LSParser.ACTION_INSERT_BEFORE); Document temp = par.parse(input); Node newNode = ctx.doc.adoptNode(temp.getDocumentElement()); node.getParentNode().insertBefore(newNode, node); TodoElement it = TodoElement.getTodoElement((Element)newNode, this.ctx, this); toProcess.add(it); } node.getParentNode().removeChild(node); this.ownerDeque.registerAtStart(toProcess); } }