class XmlBxmlNodeVisitor implements BxmlNodeVisitor {

    @Override
    public void visit(OpenStartElementNode openStartElementNode) throws IOException {
        try {
            xmlStreamWriter.writeStartElement(openStartElementNode.getTagName());
            try {
                List<BxmlNode> nonAttributeChildren = new ArrayList<>();
                for (BxmlNode bxmlNode : openStartElementNode.getChildren()) {
                    if (bxmlNode instanceof AttributeNode) {
                        bxmlNode.accept(this);
                    } else {
                        nonAttributeChildren.add(bxmlNode);
                    }
                }
                for (BxmlNode nonAttributeChild : nonAttributeChildren) {
                    nonAttributeChild.accept(this);
                }
            } finally {
                xmlStreamWriter.writeEndElement();
            }
        } catch (XMLStreamException e) {
            throw new IOException(e);
        }
    }

    public  XmlBxmlNodeVisitor(XMLStreamWriter xmlStreamWriter, RootNode rootNode);

}