code: public static void ensureNamespaceDeclDeclared(
          SerializationHandler handler,
          DTM dtm,
          int namespace)
          throws org.xml.sax.SAXException
      {
  
          String uri = dtm.getNodeValue(namespace);
          String prefix = dtm.getNodeNameX(namespace);
  
          if ((uri != null && uri.length() > 0) && (null != prefix))
          {
              String foundURI;
              NamespaceMappings ns = handler.getNamespaceMappings();
              if (ns != null)
              {
  
                  foundURI = ns.lookupNamespace(prefix);
                  if ((null == foundURI) || !foundURI.equals(uri))
                  {
                      handler.startPrefixMapping(prefix, uri, false);
                  }
              }
          }
      }
docs: This function checks to make sure a given prefix is really
  declared.  It might not be, because it may be an excluded prefix.
  If it's not, it still needs to be declared at this point.
  TODO: This needs to be done at an earlier stage in the game... -sb
  
  NEEDSDOC @param dtm
  NEEDSDOC @param namespace
  
  @throws org.xml.sax.SAXException