【问题标题】:XML Parsing in Alfresco via Javascript通过 Javascript 在 Alfresco 中解析 XML
【发布时间】:2015-05-03 13:34:55
【问题描述】:

我想在 Alfresco 中定义一个规则 - 将是一个 Javascript 文件 - 它将获取上传的 XML 文档的属性并将该属性指定为该 XML 文档的标题。例如,xml 文件的 (myXml) 内容将是这样的:

<phoneEntry>         
   <name>John Smith</name>         
   <phoneNumber>435522</phoneNumber>    
</phoneEntry>

我会按照规则把xml文件的标题改成John Smith。我不知道如何用 Javascript 编写此规则。有人告诉我,Alfresco 使用 E4X 库。任何帮助将不胜感激。

【问题讨论】:

    标签: javascript xml alfresco


    【解决方案1】:

    好的,我自己找到了解决方案。我希望这对某人有所帮助。

    var docXml = new XML(document.content);
    document.name = docXml.phoneEntry.name; 
    

    【讨论】:

      【解决方案2】:

      分享端 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;
      

      切边 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 文件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多