* @param event the pull event to be copied
*/
private void copyEvent(int event) throws XPathException {
PullProvider in = getUnderlyingProvider();
Receiver out = branch;
switch (event) {
case START_DOCUMENT:
out.startDocument(0);
break;
case START_ELEMENT:
out.startElement(in.getNameCode(), in.getTypeAnnotation(), 0, 0);
NamespaceDeclarations decl = in.getNamespaceDeclarations();
for (int i=0; i<decl.getNumberOfNamespaces(); i++) {
out.namespace(decl.getNamespaceCode(i), 0);
}
AttributeCollection atts = in.getAttributes();
for (int i=0; i<atts.getLength(); i++) {
out.attribute(atts.getNameCode(i), atts.getTypeAnnotation(i),
atts.getValue(i), 0, atts.getProperties(i));
}
out.startContent();
break;
case TEXT:
out.characters(in.getStringValue(), 0, 0);
break;
case COMMENT:
out.comment(in.getStringValue(), 0, 0);
break;
case PROCESSING_INSTRUCTION:
out.processingInstruction(
in.getPipelineConfiguration().getConfiguration().getNamePool().getLocalName(in.getNameCode()),
in.getStringValue(), 0, 0);
break;
case END_ELEMENT:
out.endElement();
break;
case END_DOCUMENT:
List entities = in.getUnparsedEntities();
if (entities != null) {
for (int i=0; i<entities.size(); i++) {
UnparsedEntity ue = (UnparsedEntity)entities.get(i);
out.setUnparsedEntity(ue.getName(), ue.getSystemId(), ue.getPublicId());
}
}
out.endDocument();
break;
case END_OF_INPUT:
in.close();
//out.close();
break;
case ATOMIC_VALUE:
if (out instanceof SequenceReceiver) {
((SequenceReceiver)out).append(super.getAtomicValue(), 0, 0);
break;
} else {
if (previousAtomic) {
out.characters(" ", 0, 0);
}
CharSequence chars = in.getStringValue();
out.characters(chars, 0, 0);
break;
}
case ATTRIBUTE:
if (out instanceof SequenceReceiver) {
Orphan o = new Orphan(in.getPipelineConfiguration().getConfiguration());
o.setNameCode(getNameCode());
o.setNodeKind(Type.ATTRIBUTE);
o.setStringValue(getStringValue());
((SequenceReceiver)out).append(o, 0, 0);
break;
} else {
out.attribute(getNameCode(), getTypeAnnotation(), getStringValue(), 0, 0);
break;
//throw new XPathException("Cannot serialize a free-standing attribute node");
}
case NAMESPACE:
if (out instanceof SequenceReceiver) {
Orphan o = new Orphan(in.getPipelineConfiguration().getConfiguration());
o.setNameCode(getNameCode());
o.setNodeKind(Type.NAMESPACE);
o.setStringValue(getStringValue());
((SequenceReceiver)out).append(o, 0, 0);
break;
} else {
int nsCode = getNamePool().getNamespaceCode(getNameCode());
out.namespace(nsCode, 0);
break;
//throw new XPathException("Cannot serialize a free-standing namespace node");
}
default: