@Override
    public int size() {
        int size = 0;

        try {
            // Get an iterator for the XMP packet, starting at the top level schema nodes
            XMPIterator nsIter = xmpData.iterator(
                    new IteratorOptions().setJustChildren(true).setOmitQualifiers(true));
            // iterate all top level namespaces
            while (nsIter.hasNext()) {
                nsIter.next();
                size++;
            }
        } catch (XMPException e) {
            // ignore
        }

        return size;
    }
Returns the number of top-level namespaces
tika-xmp/src/main/java/org/apache/tika/xmp/XMPMetadata.java