Index: src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java =================================================================== --- src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java (revision 191701) +++ src/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java (working copy) @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Properties; import java.util.Vector; import javax.jcr.PropertyType; @@ -43,7 +44,7 @@ * Node type definition reader. This class is used to read the * persistent node type definition files used by Jackrabbit. */ -public final class NodeTypeReader { +public class NodeTypeReader { /** * Reads a node type definition file. The file contents are read from @@ -83,7 +84,7 @@ * @param xml node type definition file * @throws IOException if the node type definition file cannot be read */ - private NodeTypeReader(InputStream xml) throws IOException { + protected NodeTypeReader(InputStream xml) throws IOException { walker = new DOMWalker(xml); resolver = new AdditionalNamespaceResolver(walker.getNamespaces()); } @@ -99,7 +100,7 @@ * @throws UnknownPrefixException if a definition contains an * unknown namespace prefix */ - private NodeTypeDef[] getNodeTypeDefs() + protected NodeTypeDef[] getNodeTypeDefs() throws InvalidNodeTypeDefException, IllegalNameException, UnknownPrefixException { Vector defs = new Vector(); @@ -318,4 +319,11 @@ return def; } + /** + * Returns the namespaces declared in the node type definition + * file. + */ + protected Properties getNamespaces() { + return walker.getNamespaces(); + } } Index: src/java/org/apache/jackrabbit/core/util/DOMWalker.java =================================================================== --- src/java/org/apache/jackrabbit/core/util/DOMWalker.java (revision 191701) +++ src/java/org/apache/jackrabbit/core/util/DOMWalker.java (working copy) @@ -56,6 +56,9 @@ /** The current element. */ private Element current; + /** The namespace mappings defined in the current element. */ + private Properties namespaces; + /** * Creates a walker for traversing a DOM document read from the given * input stream. The root element of the document is set as the current @@ -85,13 +88,15 @@ * @return prefix to namespace mappings of the current element */ public Properties getNamespaces() { - Properties namespaces = new Properties(); - NamedNodeMap attributes = current.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { - Attr attribute = (Attr) attributes.item(i); - if (attribute.getName().startsWith("xmlns:")) { - namespaces.setProperty( - attribute.getName().substring(6), attribute.getValue()); + if (namespaces == null) { + namespaces = new Properties(); + NamedNodeMap attributes = current.getAttributes(); + for (int i = 0; i < attributes.getLength(); i++) { + Attr attribute = (Attr) attributes.item(i); + if (attribute.getName().startsWith("xmlns:")) { + namespaces.setProperty(attribute.getName().substring(6), + attribute.getValue()); + } } } return namespaces;