Moodle
  1. Moodle
  2. MDL-13157

Create a standard method of writing xml files

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: STABLE backlog
    • Component/s: Libraries
    • Labels:
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      566

      Description

      Currently we create xml files in a number of different places ( e.g. gradebook, database presets, backups, choices, xmldb) and we haven't got a standard solid way to do it. == bugs and inconsistencies

      We should probably come up with a standard method of writing xml files and covert all previous locations to use it.

        Issue Links

          Activity

          Hide
          Penny Leach added a comment -

          Any examples of a good way you think? I need to add this for writing LEAP in the portfolio stuff.

          Show
          Penny Leach added a comment - Any examples of a good way you think? I need to add this for writing LEAP in the portfolio stuff.
          Hide
          Penny Leach added a comment -

          I kind of want to tear out the Mahara LEAP export into a LEAP writing library actually and then just use that in Moodle... it uses smarty at the moment, which I guess isn't an option.

          Show
          Penny Leach added a comment - I kind of want to tear out the Mahara LEAP export into a LEAP writing library actually and then just use that in Moodle... it uses smarty at the moment, which I guess isn't an option.
          Hide
          Sam Marshall added a comment -

          backuplib.php has functions full_tag, start_tag, end_tag, xml_safe_content or something.

          these are not appropriate for use elsewhere but could be the basis for a simple class. Making a stream-based XML-writer is not exactly rocket science - a nice class for it (so that it can do pretty-print and stuff, and throw errors if you write the close tags in the wrong order) should probably be under 100 lines.

          Also note in cases where a (php5) DOM representation already exists in memory then the DOMDocument::saveXML method should be used, regardless of any other stream-based writer implementation that might get done. however if you want to write in a stream way, it isn't efficient to construct an in-memory DOM first, so this may not be a good general approach.

          Show
          Sam Marshall added a comment - backuplib.php has functions full_tag, start_tag, end_tag, xml_safe_content or something. these are not appropriate for use elsewhere but could be the basis for a simple class. Making a stream-based XML-writer is not exactly rocket science - a nice class for it (so that it can do pretty-print and stuff, and throw errors if you write the close tags in the wrong order) should probably be under 100 lines. Also note in cases where a (php5) DOM representation already exists in memory then the DOMDocument::saveXML method should be used, regardless of any other stream-based writer implementation that might get done. however if you want to write in a stream way, it isn't efficient to construct an in-memory DOM first, so this may not be a good general approach.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          NOTE: This issue was assigned to the STABLE backlog without complete triaging process. Marking it as triaged, but with this note for future reference.

          Show
          Eloy Lafuente (stronk7) added a comment - NOTE: This issue was assigned to the STABLE backlog without complete triaging process. Marking it as triaged, but with this note for future reference.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: