jjzjj

xml - 对于从露天中的另一个模型继承的模型,它们是否需要具有不同的 namespace 或者它们是否可以共享相同的 namespace ?

coder 2024-06-30 原文

所以我有 2 个模型。我有一个“medicalBillModel”,我想从“clientDocument”继承。出于某种原因,当我这样做时,我得到的错误基本上是说命名空间已经被定义了。当我有一个模型继承自露天的另一个模型时,它们是否需要具有不同的命名空间,或者它们是否可以共享相同的命名空间?

我还尝试导入命名空间并删除命名空间声明,但这会导致此错误:

Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 06210000 Cannot define class ag:medicalBill as namespace http://www.company.com/model/content/1.0 is not defined by model ag:medicalBill

我目前正在谷歌搜索,但没有找到一个自定义模型继承自另一个模型的示例。

clientDocumentModel.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- Definition of new Model -->

<model name="ag:clientDocument" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!-- Optional meta-data about the model -->  

   <description>General Client Document</description>
   <author>James Pearson</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.company.com/model/content/1.0" prefix="ag"/>
   </namespaces>

   <types>

      <type name="ag:clientDocument">
         <title>General Client Document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="ag:clientName">
               <title>Client</title>
                <type>d:text</type>
            </property>
         </properties>
      </type>

    </types>

</model>

medicalBillModel.xml

<?xml version="1.0" encoding="UTF-8"?>

<model name="ag:medicalBill" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <description>Medical Bill</description>
   <author>James Pearson</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
      <import uri="http://www.company.com/model/content/1.0" prefix="ag"/>
   </imports>


   <types>

      <!-- Definition of new Content Type: Standard Operating Procedure -->
      <type name="ag:medicalBill">
         <title>Medical Bill</title>
         <parent>ag:clientDocument</parent>
         <properties>

            <property name="ag:patientNameFirst">
               <title>Patient First Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientNameLast">
               <title>Patient Last Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientMiddleInitial">
               <title>Patient Middle Initial</title>
                    <type>d:text</type>
            </property>

            <property name="ag:totalBillCharges">
                    <title>Total Bill Charges</title>
               <type>d:double</type>
            </property>

                <property name="ag:dateAdmitted">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

                <property name="ag:dateDischarged">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

            <property name="ag:facility">
                    <title>Facility Name</title>
               <type>d:text</type>
            </property>

         </properties>
      </type>

    </types>

    <aspects>

   </aspects>

</model>

最佳答案

您好,每个内容模型都可以有一个或多个唯一的命名空间,请查看 Wiki

我知道它没有明确说明它必须是唯一的。但确实如此。

我不明白为什么要在不同的 xml 中使用相同的命名空间?

只需在一个内容模型中使用多种类型,如下所示:

<model name="ag:clientDocument" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!-- Optional meta-data about the model -->  

   <description>General Client Document</description>
   <author>James Pearson</author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.company.com/model/content/1.0" prefix="ag"/>
   </namespaces>

   <types>

      <type name="ag:clientDocument">
         <title>General Client Document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="ag:clientName">
               <title>Client</title>
                <type>d:text</type>
            </property>
         </properties>
      </type>

<!-- Definition of new Content Type: Standard Operating Procedure -->
      <type name="ag:medicalBill">
         <title>Medical Bill</title>
         <parent>ag:clientDocument</parent>
         <properties>

            <property name="ag:patientNameFirst">
               <title>Patient First Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientNameLast">
               <title>Patient Last Name</title>
                    <type>d:text</type>
            </property>

            <property name="ag:patientMiddleInitial">
               <title>Patient Middle Initial</title>
                    <type>d:text</type>
            </property>

            <property name="ag:totalBillCharges">
                    <title>Total Bill Charges</title>
               <type>d:double</type>
            </property>

                <property name="ag:dateAdmitted">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

                <property name="ag:dateDischarged">
                    <title>Facility Name</title>
               <type>d:date</type>
            </property>

            <property name="ag:facility">
                    <title>Facility Name</title>
               <type>d:text</type>
            </property>

         </properties>
      </type>

    </types>

</model>

通常我在一个内容模型中有很多类型。所以您不必担心。

如果您仍想将它们分开,请使用不同的命名空间并导入一个又一个。 顺便说一句,为什么要在 MedicalBill 中导入 ClientModel?我没有看到它的任何用法?

关于xml - 对于从露天中的另一个模型继承的模型,它们是否需要具有不同的 namespace 或者它们是否可以共享相同的 namespace ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6783898/

有关xml - 对于从露天中的另一个模型继承的模型,它们是否需要具有不同的 namespace 或者它们是否可以共享相同的 namespace ?的更多相关文章

  1. ruby - 我需要将 Bundler 本身添加到 Gemfile 中吗? - 2

    当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/

  2. ruby-on-rails - 如何验证 update_all 是否实际在 Rails 中更新 - 2

    给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru

  3. ruby-on-rails - Rails - 子类化模型的设计模式是什么? - 2

    我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co

  4. ruby - 什么是填充的 Base64 编码字符串以及如何在 ruby​​ 中生成它们? - 2

    我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%

  5. ruby-on-rails - Rails - 一个 View 中的多个模型 - 2

    我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何

  6. ruby-on-rails - 渲染另一个 Controller 的 View - 2

    我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>

  7. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  8. ruby-on-rails - 在混合/模块中覆盖模型的属性访问器 - 2

    我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah

  9. ruby-on-rails - 如何验证非模型(甚至非对象)字段 - 2

    我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss

  10. ruby-on-rails - form_for 中不在模型中的自定义字段 - 2

    我想向我的Controller传递一个参数,它是一个简单的复选框,但我不知道如何在模型的form_for中引入它,这是我的观点:{:id=>'go_finance'}do|f|%>Transferirde:para:Entrada:"input",:placeholder=>"Quantofoiganho?"%>Saída:"output",:placeholder=>"Quantofoigasto?"%>Nota:我想做一个额外的复选框,但我该怎么做,模型中没有一个对象,而是一个要检查的对象,以便在Controller中创建一个ifelse,如果没有检查,请帮助我,非常感谢,谢谢

随机推荐