code: private XmlDocument makeDocument(String name, String document)
              throws XmlException, PolicyIndexException {
          Map<String, String> metadata =
                  m_utils.getDocumentMetadata(document
                          .getBytes());
          XmlDocument doc = m_dbXmlManager.manager.createDocument();
          String docName = name;
  
          if (docName == null || docName.isEmpty()) {
              docName = metadata.get("PolicyId");
          }
  
          if (docName == null || docName.isEmpty()) {
              throw new PolicyIndexException("Could not extract PolicyID from document.");
          }
  
          doc.setMetaData("metadata", "PolicyId", new XmlValue(XmlValue.STRING,
                                                               docName));
          doc.setContent(document);
          doc.setName(docName);
  
          // FIXME:
          // this is probably redundant as the xpath queries now directly query the policy
          // for the "any" scenarios
          String item = null;
          item = metadata.get("anySubject");
          if (item != null) {
              doc.setMetaData("metadata",
                              "anySubject",
                              new XmlValue(XmlValue.STRING, item));
          }
  
          item = metadata.get("anyResource");
          if (item != null) {
              doc.setMetaData("metadata",
                              "anyResource",
                              new XmlValue(XmlValue.STRING, item));
          }
  
          item = metadata.get("anyAction");
          if (item != null) {
              doc.setMetaData("metadata",
                              "anyAction",
                              new XmlValue(XmlValue.STRING, item));
          }
  
          item = metadata.get("anyEnvironment");
          if (item != null) {
              doc.setMetaData("metadata",
                              "anyEnvironment",
                              new XmlValue(XmlValue.STRING, item));
          }
  
          return doc;
      }
docs: Creates an instance of an XmlDocument for storage in the database.
  
  @param name
  the name of the document (policy)
  @param document
  the document data as a String
  @return the XmlDocument instance
  @throws XmlException
  @throws PolicyStoreException