package org.libj.xquery.xml.str;

import org.libj.xquery.xml.XML;
import org.libj.xquery.xml.XMLFactory;

import java.util.HashMap;
import java.util.Map;

public class StringNamespaceXMLFactory implements XMLFactory {
    private Map<String, String> namespaces = new HashMap<String, String>();
    public XML toXML(String xml) {
        return new StringNamespaceXML(xml, namespaces);
    }

    public void registerNamespace(String prefix, String namespace) {
        namespaces.put(prefix, namespace);
    }
}

@@ -503,10 +503,315 @@
 ;%0A    %7D%0A
+%0A    public static final XMLFactory SHARED_FACTORY = new StringNamespaceXMLFactory() %7B%0A        @Override%0A        public void registerNamespace(String prefix, String namespace) %7B%0A            throw new UnsupportedOperationException(%22StringNamespaceXMLFactory.SHARED_FACTORY is readonly%22);%0A        %7D%0A    %7D;%0A%0A
 %7D%0A

create a immutable shared factory (can't register namespace), in the case factory creation is bottleneck