@@ -0,0 +1,2594 @@
+/*%0A * Copyright (C) 2010 TranceCode Software%0A *%0A * This library is free software; you can redistribute it and/or modify it under%0A * the terms of the GNU Lesser General Public License as published by the Free%0A * Software Foundation; either version 2.1 of the License, or (at your option)%0A * any later version.%0A * %0A * This library is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS%0A * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more%0A * details.%0A * %0A * You should have received a copy of the GNU Lesser General Public License%0A * along with this library; if not, write to the Free Software Foundation, Inc.,%0A * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %0A */%0Apackage org.trancecode.xml.saxon;%0A%0Aimport com.google.common.base.Function;%0Aimport com.google.common.collect.Iterables;%0Aimport com.google.common.collect.Maps;%0A%0Aimport java.util.Iterator;%0Aimport java.util.Map;%0Aimport java.util.Map.Entry;%0A%0Aimport net.sf.saxon.om.InscopeNamespaceResolver;%0Aimport net.sf.saxon.s9api.XdmNode;%0Aimport org.trancecode.collection.TcMaps;%0A%0A/**%0A * Utility methods realted to namespaces for Saxon.%0A * %0A * @author Herve Quiroz%0A */%0Apublic final class SaxonNamespaces%0A%7B%0A    public static Iterable%3CString%3E prefixes(final XdmNode node)%0A    %7B%0A        return new Iterable%3CString%3E()%0A        %7B%0A            @Override%0A            public Iterator%3CString%3E iterator()%0A            %7B%0A                final InscopeNamespaceResolver namespaceResolver = new InscopeNamespaceResolver(%0A                        node.getUnderlyingNode());%0A                @SuppressWarnings(%22unchecked%22)%0A                final Iterator%3CString%3E prefixes = namespaceResolver.iteratePrefixes();%0A                return prefixes;%0A            %7D%0A        %7D;%0A    %7D%0A%0A    public static Iterable%3CEntry%3CString, String%3E%3E namespaceSequence(final XdmNode node)%0A    %7B%0A        final InscopeNamespaceResolver namespaceResolver = new InscopeNamespaceResolver(node.getUnderlyingNode());%0A        return Iterables.transform(prefixes(node), new Function%3CString, Entry%3CString, String%3E%3E()%0A        %7B%0A            @Override%0A            public Entry%3CString, String%3E apply(final String prefix)%0A            %7B%0A                return Maps.immutableEntry(prefix, namespaceResolver.getURIForPrefix(prefix, true));%0A            %7D%0A        %7D);%0A    %7D%0A%0A    public static Map%3CString, String%3E namespaceMap(final XdmNode node)%0A    %7B%0A        return TcMaps.fromEntries(namespaceSequence(node));%0A    %7D%0A%0A    private SaxonNamespaces()%0A    %7B%0A        // No instantiation%0A    %7D%0A%7D%0A

Add SaxonNamespaces