Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5399

Add and fix config xml dtd files 1-0.1.5

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Must
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.2.0
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Medium

      Description

      Add the DTD files for the config.xml in versions 1.0-1.5 to the resources of org/openmrs/module/dtd so they are under version control, can easily be found, edited and uploaded back to resource.openmrs.org. Fix the DTDs since they are currently invalid (refering to elements which are not declared), cannot be used by IDEs and are thus not useful for devs writing their config.xml.

      After the fix a dev can download the DTD into the IDE via the link in the doctype for example:

      <!DOCTYPE module PUBLIC "-//OpenMRS//DTD OpenMRS Config 1.0//EN"
                               "http://resources.openmrs.org/doctype/config-1.2.dtd">
      

      And get direct response when making an error in the xml

      NOTE: the DTDs currently (12.05.2018) on http://resources.openmrs.org are attached to the issue so anyone can still find them once we upload the fixed DTDs to http://resources.openmrs.org.

      SUMMARY OF FIXES:

      I fixed DTDs according to descriptions here https://wiki.openmrs.org/display/docs/Module+Config+File and by searching github.com to double check on how modules define their config.xml.

      dwr

      • add missing elements judging from legacyui dwr element in config.xml
      • create (param, include*) always has a param and can have 0-N include's
        param and include are empty elements with required attributes
      • convert has one optional param child

      mappingFiles

      • fix the mappingFiles quantifier since it should only occur Zero or One
        time thus use `?`. mappingFiles itself can have multiple whitespace
        separated filenames

      require_modules

      • be more strict on `require_modules` which should have 1-N `require_module`
        instead of 0-N, because why declare it if you dont require any module

      aware_of_modules

      • add `aware_of_modules` element to version 1.4, which was missing in
        the file uploaded to resources.openmrs.org and this also has to have 1-N
        `aware_of_module` if added

      filter

      has 1 filter-name and filter-class and 0-N inti-param elements

      Example
      https://github.com/openmrs/openmrs-module-personalhr/blob/19a4acf9c3ec9063f12dfb6b176c1bad16944da9/omod/src/main/resources/config.xml#L108-L123

      filter-mapping

      • filter-mapping added in 1.2 defines that one of the following
        url-pattern or servlet-name elements must be included thus the pattern
        (url-pattern | servlet-name)

      You can see some of above fixes in the difference between the fixed DTD 1.0 and the DTD 1.0 currently (12.05.2018) on http://resources.openmrs.org/doctype/ (diff is large due to making formatting consistent)

      diff -u ~/code/openmrs/documents/config-xml-resources-openmrs-org-2018-05-12/config-1.0.dtd config-1.0.dtd
      --- /Users/iulrich/code/openmrs/documents/config-xml-resources-openmrs-org-2018-05-12/config-1.0.dtd	2018-05-12 08:20:46.000000000 +0200
      +++ config-1.0.dtd	2018-05-12 07:46:08.000000000 +0200
      @@ -1,51 +1,87 @@
       <?xml version="1.0" encoding="UTF-8"?>
      
      -<!--
      -Top level configuration element.
      --->
      -<!ELEMENT module (
      -    (id),
      -    (name),
      -    (version),
      -    (package),
      -    (author),
      -    (description),
      -    (activator),
      -    (updateURL?),
      -    (require_version?),
      -    (require_database_version?),
      -    (require_modules?),
      -    (library*),
      -    (extension*),
      -    (advice*),
      -    (privilege*),
      -    (globalProperty*),
      -    (dwr?),
      -    (servlet*),
      -    (messages*),
      -    (mappingFiles*)
      -)>
      -<!ATTLIST module configVersion CDATA #FIXED "1.0">
      -
      -<!ELEMENT library EMPTY>
      -<!ATTLIST library
      -	id CDATA #REQUIRED
      -	path CDATA #REQUIRED
      -	type (resources|library) #REQUIRED
      ->
      -
      -<!ELEMENT extension (point, class)>
      -
      -<!ELEMENT advice (point, class)>
      -
      -<!ELEMENT privilege (name, description)>
      -
      -<!ELEMENT globalProperty (property, defaultValue?, description)>
      +	<!--
      +	Top level configuration element.
      +	-->
      +	<!ELEMENT module (
      +		(id),
      +		(name),
      +		(version),
      +		(package),
      +		(author),
      +		(description),
      +		(activator),
      +		(updateURL?),
      +		(require_version?),
      +		(require_database_version?),
      +		(require_modules?),
      +		(library*),
      +		(extension*),
      +		(advice*),
      +		(privilege*),
      +		(globalProperty*),
      +		(dwr?),
      +		(servlet*),
      +		(messages*),
      +		(mappingFiles?)
      +		)>
      +	<!ATTLIST module configVersion CDATA #FIXED "1.0">
      +
      +	<!ELEMENT id (#PCDATA)>
      +	<!ELEMENT name (#PCDATA)>
      +	<!ELEMENT version (#PCDATA)>
      +	<!ELEMENT package (#PCDATA)>
      +	<!ELEMENT author (#PCDATA)>
      +	<!ELEMENT description (#PCDATA)>
      +	<!ELEMENT activator (#PCDATA)>
      +	<!ELEMENT updateURL (#PCDATA)>
      +	<!ELEMENT require_version (#PCDATA)>
      +	<!ELEMENT require_database_version (#PCDATA)>
      +
      +	<!ELEMENT require_modules (require_module+)>
      +	<!ELEMENT require_module (#PCDATA)>
      +
      +	<!ELEMENT library EMPTY>
      +	<!ATTLIST library
      +		id CDATA #REQUIRED
      +		path CDATA #REQUIRED
      +		type (resources|library) #REQUIRED
      +		>
      +
      +	<!ELEMENT extension (point, class)>
      +	<!ELEMENT advice (point, class)>
      +	<!ELEMENT point (#PCDATA)>
      +	<!ELEMENT class (#PCDATA)>
      +
      +	<!ELEMENT privilege (name, description)>
      +
      +	<!ELEMENT globalProperty (property, defaultValue?, description)>
      +	<!ELEMENT property (#PCDATA)>
      +	<!ELEMENT defaultValue (#PCDATA)>
      +
      +	<!ELEMENT dwr (allow, signatures?)>
      +	<!ELEMENT allow (create*, convert*)>
      +
      +	<!ELEMENT create (param, include*)>
      +	<!ATTLIST create creator CDATA #REQUIRED javascript CDATA #REQUIRED>
      +
      +	<!ELEMENT param EMPTY>
      +	<!ATTLIST param name CDATA #REQUIRED value CDATA #REQUIRED>
      +
      +	<!ELEMENT include EMPTY>
      +	<!ATTLIST include method CDATA #REQUIRED>
      +
      +	<!ELEMENT convert (param?)>
      +	<!ATTLIST convert converter CDATA #REQUIRED match CDATA #REQUIRED>
      +
      +	<!ELEMENT signatures (#PCDATA)>
      +
      +	<!ELEMENT servlet (servlet-name, servlet-class)>
      +	<!ELEMENT servlet-name (#PCDATA)>
      +	<!ELEMENT servlet-class (#PCDATA)>
      +
      +	<!ELEMENT messages (lang, file)>
      +	<!ELEMENT lang (#PCDATA)>
      +	<!ELEMENT file (#PCDATA)>
      
      -<!ELEMENT dwr (allow, signatures?)>
      -
      -<!ELEMENT servlet (servlet-name, servlet-class)>
      -
      -<!ELEMENT messages (lang, file)>
      -
      -<!ELEMENT require_modules (require_module*)>
      +	<!ELEMENT mappingFiles (#PCDATA)>
      

      Difference between the DTD Versions after the fix

      follows the Config.dtd Version History:

      diff -u config-1.0.dtd config-1.1.dtd
      --- config-1.0.dtd	2018-05-12 07:46:08.000000000 +0200
      +++ config-1.1.dtd	2018-05-12 07:46:08.000000000 +0200
      @@ -25,7 +25,7 @@
       		(messages*),
       		(mappingFiles?)
       		)>
      -	<!ATTLIST module configVersion CDATA #FIXED "1.0">
      +	<!ATTLIST module configVersion CDATA #FIXED "1.1">
      
       	<!ELEMENT id (#PCDATA)>
       	<!ELEMENT name (#PCDATA)>
      @@ -40,6 +40,7 @@
      
       	<!ELEMENT require_modules (require_module+)>
       	<!ELEMENT require_module (#PCDATA)>
      +	<!ATTLIST require_module version CDATA #IMPLIED>
      
       	<!ELEMENT library EMPTY>
       	<!ATTLIST library
      
      diff -u config-1.1.dtd config-1.2.dtd
      --- config-1.1.dtd	2018-05-12 07:46:08.000000000 +0200
      +++ config-1.2.dtd	2018-05-12 07:46:08.000000000 +0200
      @@ -22,10 +22,12 @@
       		(globalProperty*),
       		(dwr?),
       		(servlet*),
      +		(filter*),
      +		(filter-mapping*),
       		(messages*),
       		(mappingFiles?)
       		)>
      -	<!ATTLIST module configVersion CDATA #FIXED "1.1">
      +	<!ATTLIST module configVersion CDATA #FIXED "1.2">
      
       	<!ELEMENT id (#PCDATA)>
       	<!ELEMENT name (#PCDATA)>
      @@ -81,6 +83,16 @@
       	<!ELEMENT servlet-name (#PCDATA)>
       	<!ELEMENT servlet-class (#PCDATA)>
      
      +	<!ELEMENT filter (filter-name, filter-class, init-param*)>
      +	<!ELEMENT filter-name (#PCDATA)>
      +	<!ELEMENT filter-class (#PCDATA)>
      +	<!ELEMENT init-param (param-name, param-value)>
      +	<!ELEMENT param-name (#PCDATA)>
      +	<!ELEMENT param-value (#PCDATA)>
      +
      +	<!ELEMENT filter-mapping (filter-name, (url-pattern | servlet-name))>
      +	<!ELEMENT url-pattern (#PCDATA)>
      +
       	<!ELEMENT messages (lang, file)>
       	<!ELEMENT lang (#PCDATA)>
       	<!ELEMENT file (#PCDATA)>
      
      diff -u config-1.2.dtd config-1.3.dtd
      --- config-1.2.dtd	2018-05-12 07:46:08.000000000 +0200
      +++ config-1.3.dtd	2018-05-12 07:46:08.000000000 +0200
      @@ -15,6 +15,7 @@
       		(require_version?),
       		(require_database_version?),
       		(require_modules?),
      +		(mandatory?),
       		(library*),
       		(extension*),
       		(advice*),
      @@ -27,7 +28,7 @@
       		(messages*),
       		(mappingFiles?)
       		)>
      -	<!ATTLIST module configVersion CDATA #FIXED "1.2">
      +	<!ATTLIST module configVersion CDATA #FIXED "1.3">
      
       	<!ELEMENT id (#PCDATA)>
       	<!ELEMENT name (#PCDATA)>
      @@ -44,6 +45,8 @@
       	<!ELEMENT require_module (#PCDATA)>
       	<!ATTLIST require_module version CDATA #IMPLIED>
      
      +	<!ELEMENT mandatory (#PCDATA)>
      +
       	<!ELEMENT library EMPTY>
       	<!ATTLIST library
       		id CDATA #REQUIRED
      
      diff -u config-1.3.dtd config-1.4.dtd
      --- config-1.3.dtd	2018-05-12 07:46:08.000000000 +0200
      +++ config-1.4.dtd	2018-05-12 07:46:08.000000000 +0200
      @@ -15,6 +15,7 @@
       		(require_version?),
       		(require_database_version?),
       		(require_modules?),
      +		(aware_of_modules?),
       		(mandatory?),
       		(library*),
       		(extension*),
      @@ -28,7 +29,7 @@
       		(messages*),
       		(mappingFiles?)
       		)>
      -	<!ATTLIST module configVersion CDATA #FIXED "1.3">
      +	<!ATTLIST module configVersion CDATA #FIXED "1.4">
      
       	<!ELEMENT id (#PCDATA)>
       	<!ELEMENT name (#PCDATA)>
      @@ -45,6 +46,10 @@
       	<!ELEMENT require_module (#PCDATA)>
       	<!ATTLIST require_module version CDATA #IMPLIED>
      
      +	<!ELEMENT aware_of_modules (aware_of_module+)>
      +	<!ELEMENT aware_of_module (#PCDATA)>
      +	<!ATTLIST aware_of_module version CDATA #IMPLIED>
      +
       	<!ELEMENT mandatory (#PCDATA)>
      
       	<!ELEMENT library EMPTY>
      
      diff -u config-1.4.dtd config-1.5.dtd
      --- config-1.4.dtd	2018-05-12 07:46:08.000000000 +0200
      +++ config-1.5.dtd	2018-05-12 07:46:08.000000000 +0200
      @@ -28,8 +28,9 @@
       		(filter-mapping*),
       		(messages*),
       		(mappingFiles?)
      +		(packagesWithMappedClasses?)
       		)>
      -	<!ATTLIST module configVersion CDATA #FIXED "1.4">
      +	<!ATTLIST module configVersion CDATA #FIXED "1.5">
      
       	<!ELEMENT id (#PCDATA)>
       	<!ELEMENT name (#PCDATA)>
      @@ -106,3 +107,4 @@
       	<!ELEMENT file (#PCDATA)>
      
       	<!ELEMENT mappingFiles (#PCDATA)>
      +	<!ELEMENT packagesWithMappedClasses (#PCDATA)>
      

        Attachments

        1. config-1.0.dtd
          1.0 kB
        2. config-1.1.dtd
          1 kB
        3. config-1.2.dtd
          1 kB
        4. config-1.3.dtd
          1 kB
        5. config-1.4.dtd
          1 kB
        6. config-1.5.dtd
          1 kB
        7. Screen Shot 2018-05-12 at 08.34.04.png
          Screen Shot 2018-05-12 at 08.34.04.png
          164 kB

          Activity

            People

            Assignee:
            teleivo Ivo Ulrich
            Reporter:
            teleivo Ivo Ulrich
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: