XML 通过 Javascript 在 Alfresco 中解析
XML Parsing in Alfresco via Javascript
我想在 Alfresco 中定义一个规则 - 将是一个 Javascript 文件 - 它将获得上传的 XML 文档的 属性 并分配给 属性作为该 XML 文档的标题。例如,xml 文件的 (myXml
) 内容将是这样的:
<phoneEntry>
<name>John Smith</name>
<phoneNumber>435522</phoneNumber>
</phoneEntry>
我会按照规则将xml文件的标题改为John Smith
。我不知道如何在Javascript中写这个规则。我听说 Alfresco 使用 E4X
库。任何帮助将不胜感激。
好的,我已经自己找到了解决方案。我希望这对某人有所帮助。
var docXml = new XML(document.content);
document.name = docXml.phoneEntry.name;
分享端Javascript文件
var myConfig = new XML();
var configNodeRef = getConfigNodeRef("Data%20Dictionary/Configurations/solution_data.xml");
if (configNodeRef != null) {
logger.log("create new configNodeRef: " + configNodeRef);
var configContent = getConfigContent(configNodeRef);
if (configContent != null && configContent != "") {
try
{
myConfig = new XML(configContent);
}
catch (e)
{
logger.log(e);
}
}
}
model.configNodeRef = configNodeRef;
Shre 端 Ftl 文件。
{
"result" : "<#list result as r>${r.label}<#if r_has_next>,</#if></#list>"
}
Xml 文件的一部分
<Human_Resources label="Human_Resources">
<Human_Capital_Management label="Human_Capital_Management" />
<Payroll label="Payroll" />
<Talent_Management label="Talent_Management" />
<HR_Service_Delivery label="HR_Service_Delivery" />
</Human_Resources>
<Information_Technology label="Information_Technology">
<SAP_NetWeaver label="SAP_NetWeaver" />
<Service_Oriented_Architecture label="Service_Oriented_Architecture" />
<Enterprise_Mobility label="Enterprise_Mobility" />
<Cloud_Computing label="Cloud_Computing" />
<SAP_HANA_and_In_Memory_Computing label="SAP_HANA_and_In_Memory_Computing" />
<Content_and_Collaboration label="Content_and_Collaboration" />
<IT_Management label="IT_Management" />
<Custom_Development label="Custom_Development" />
<Database label="Database" />
<SAP_Application_Interface_Framework label="SAP_Application_Interface_Framework" />
</Information_Technology>
以上示例是在 alfresco 共享中创建的,用于从 alfresco 存储库读取 xml 文件。
我想在 Alfresco 中定义一个规则 - 将是一个 Javascript 文件 - 它将获得上传的 XML 文档的 属性 并分配给 属性作为该 XML 文档的标题。例如,xml 文件的 (myXml
) 内容将是这样的:
<phoneEntry>
<name>John Smith</name>
<phoneNumber>435522</phoneNumber>
</phoneEntry>
我会按照规则将xml文件的标题改为John Smith
。我不知道如何在Javascript中写这个规则。我听说 Alfresco 使用 E4X
库。任何帮助将不胜感激。
好的,我已经自己找到了解决方案。我希望这对某人有所帮助。
var docXml = new XML(document.content);
document.name = docXml.phoneEntry.name;
分享端Javascript文件
var myConfig = new XML();
var configNodeRef = getConfigNodeRef("Data%20Dictionary/Configurations/solution_data.xml");
if (configNodeRef != null) {
logger.log("create new configNodeRef: " + configNodeRef);
var configContent = getConfigContent(configNodeRef);
if (configContent != null && configContent != "") {
try
{
myConfig = new XML(configContent);
}
catch (e)
{
logger.log(e);
}
}
}
model.configNodeRef = configNodeRef;
Shre 端 Ftl 文件。
{
"result" : "<#list result as r>${r.label}<#if r_has_next>,</#if></#list>"
}
Xml 文件的一部分
<Human_Resources label="Human_Resources">
<Human_Capital_Management label="Human_Capital_Management" />
<Payroll label="Payroll" />
<Talent_Management label="Talent_Management" />
<HR_Service_Delivery label="HR_Service_Delivery" />
</Human_Resources>
<Information_Technology label="Information_Technology">
<SAP_NetWeaver label="SAP_NetWeaver" />
<Service_Oriented_Architecture label="Service_Oriented_Architecture" />
<Enterprise_Mobility label="Enterprise_Mobility" />
<Cloud_Computing label="Cloud_Computing" />
<SAP_HANA_and_In_Memory_Computing label="SAP_HANA_and_In_Memory_Computing" />
<Content_and_Collaboration label="Content_and_Collaboration" />
<IT_Management label="IT_Management" />
<Custom_Development label="Custom_Development" />
<Database label="Database" />
<SAP_Application_Interface_Framework label="SAP_Application_Interface_Framework" />
</Information_Technology>
以上示例是在 alfresco 共享中创建的,用于从 alfresco 存储库读取 xml 文件。