private void itemToSAX(Item item, boolean typed, boolean wrap, AttrList attrs) throws SAXException {
if(Type.subTypeOf(item.getType(), Type. NODE)) {
final NodeValue node = (NodeValue) item;
if(typed) {
//TODO the typed and wrapped stuff should ideally be replaced
//with Marshaller.marshallItem
//unfortrunately calling Marshaller.marshallItem(broker, item, new SAXToReceiver(receiver))
//results in a stack overflow
//TODO consider a full XDM serializer in place of this for these special needs
serializeTypePreNode(node);
if(node.getType() == Type.ATTRIBUTE) {
serializeTypeAttributeValue(node);
} else {
serializeToReceiver(node, false);
}
serializeTypePostNode(node);