I want to define a rule in Alfresco -will be a Javascript file- which will get a property of an uploaded XML document and assign that property as a title to that XML document. For instance, the xml file's (myXml
) content will be something like this:
我想在Alfresco中定义一个规则 - 将是一个Javascript文件 - 它将获得上传的XML文档的属性,并将该属性指定为该XML文档的标题。例如,xml文件的(myXml)内容将是这样的:
<phoneEntry>
<name>John Smith</name>
<phoneNumber>435522</phoneNumber>
</phoneEntry>
I will change the title of xml file to John Smith
by the rule. I don't know how to write this rule in Javascript. I have been told that Alfresco uses E4X
library. Any help will be appreciated.
我将通过规则将xml文件的标题更改为John Smith。我不知道如何在Javascript中编写此规则。我被告知Alfresco使用E4X库。任何帮助将不胜感激。
2 个解决方案
#1
Ok, I have found the solution by myself. I hope this helps someone.
好的,我自己找到了解决方案。我希望这可以帮助别人。
var docXml = new XML(document.content);
document.name = docXml.phoneEntry.name;
#2
Share Side Javascript File
分享Side 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 Side Ftl File.
Shre Side Ftl文件。
{
"result" : "<#list result as r>${r.label}<#if r_has_next>,</#if></#list>"
}
Portion Of Xml File
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>
Above example is created in alfresco share for reading xml file from alfresco repository.
以上示例是在alfresco共享中创建的,用于从alfresco存储库读取xml文件。
#1
Ok, I have found the solution by myself. I hope this helps someone.
好的,我自己找到了解决方案。我希望这可以帮助别人。
var docXml = new XML(document.content);
document.name = docXml.phoneEntry.name;
#2
Share Side Javascript File
分享Side 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 Side Ftl File.
Shre Side Ftl文件。
{
"result" : "<#list result as r>${r.label}<#if r_has_next>,</#if></#list>"
}
Portion Of Xml File
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>
Above example is created in alfresco share for reading xml file from alfresco repository.
以上示例是在alfresco共享中创建的,用于从alfresco存储库读取xml文件。