您最好的选择是查询文件夹中的所有文档,然后对其进行迭代,提取元数据,并以您认为最好的方式构建您的 xml。
您可以在此处找到显示如何通过 API 使用查询的代码示例。可以在此处找到查询构建语法(特别是检查文件夹运算符部分)。
现在您有了文档,只需对它们进行迭代,检索属性集合,获取各个属性,并使用适当的方法(getStringValue、getInt32Value 等)读取值
注意:如果您希望查询仅包含当前版本,而不考虑旧版本,请将此子句添加到您的查询中:([IsCurrentVersion] = TRUE)
总而言之,使用样板代码,你应该有这样的东西:(从旧代码中复制粘贴的部分,不能保证立即工作)
// Set connection parameters; usually loaded from a properties file.
String uri = "http://server:port/wsi/FNCEWS40MTOM/";
String username = "username";
String password = "password";
// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());
// Get object stores for domain.
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "OS_Name", null);
// Build the query you want to use here
// Add the attributes you want, the document class you're interested in, etc.
String sqlstr = "SELECT [This], [createdBy], [createdDate] FROM [docClass] WHERE ([IsCurrentVersion] = TRUE) AND Document.This INFOLDER '/f1/f2'";
SearchSQL sql = new SearchSQL(sqlstr)
SearchScope scope = new SearchScope(os);
IndependentObjectSet docs = scope.fetchObjects(sql, 1000, null, true);
// Get the page iterator
PageIterator p = docs.pageIterator();
// Loop through each page
while(p.nextPage())
{
// Loop through each item in the page
for(Object objct : p.getCurrentPage())
{
// Get the document object and write Document Title
Document doc = (Document)objct;
Properties props = doc.getProperties();
String creator = props.getStringValue("createdBy");
Date creationDate = props.getDateTimeValue("creationDate");
// Now that you have the values, do what you want with them :)
}
}
}