Pages

Monday, December 02, 2013

SCORM - Lesson 6

XML - An Introduction

Rama as you discovered in the previous page, XML is required for packaging SCORM-conformant courses, and for content developers, you will need to prepare this file to describe your course. The good news is that this is not difficult. The expert level packaging lesson will give you several examples to work from. However, you will still need to create your own file, and you will from time to time encounter problems with this file. Here are some essential for XML.

Tags, Elements & Attributes in XML

Lets examine a small part of an imsmanifest.xml file.

Modeling and Simulation

    Introduction and Usage

The </span></strong> and <strong><span style="font-family: "Arial","sans-serif";"><item...> </span></strong>syntax in this xml are called XML "<strong><span style="font-family: "Arial","sans-serif";">tags</span></strong>." XML tags are always used to begin an XML element. The title of this item, for example is one<strong><span style="font-family: "Arial","sans-serif";"> element</span></strong> with the tag <title> and value "Introduction and Usage." An element, then, consists of a tag and its value.<o:p></o:p></span></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">An <strong><span style="font-family: "Arial","sans-serif";">attribute</span></strong>, has the form name=value, where "name" is a particular variable name reserved for that element and "value" is the string you want to associate with that attribute. There are two attributes in this XML: identifier="ITEM1" and identifierref="INTRODUCTION." Attributes are used to provide a context to an element.<o:p></o:p></span></p> <p> <font size="3"><font face="Verdana"><span style="color: maroon; mso-bidi-font-family: Arial;"></span></font></font><br /></p> <p> <font size="3"><font face="Verdana"><span style="color: maroon; mso-bidi-font-family: Arial;">Where is the list of XML Tags and Attributes that I can use?</span><span style="mso-bidi-font-family: Arial;"><o:p></o:p></span></font></font></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">Which tags can you use? Well, each XML document has one or more companion files that define the allowed tags and their attributes. These documents are either <strong><span style="font-family: "Arial","sans-serif";">DTD</span></strong> (Document Type Declaration) files, with a file type of ".dtd", or they are <strong><span style="font-family: "Arial","sans-serif";">XML schema files</span></strong> with the file type ".xsd". In SCORM there are four of these files that are needed. They define which tags can be used in the imsmanifest.xml file as well as their attributes.<o:p></o:p></span></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">The packaging lessons in this course describe the imsmanifest.xml file and the use of the SCORM schemas in preparing this file.<o:p></o:p></span></p> <p> <font size="3"><font face="Verdana"><span style="color: maroon; mso-bidi-font-family: Arial;"></span></font></font><br /></p> <p> <font size="3"><font face="Verdana"><span style="color: maroon; mso-bidi-font-family: Arial;">Where do I obtain the SCORM XML DTDs and Schemas?</span><span style="mso-bidi-font-family: Arial;"><o:p></o:p></span></font></font></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">You can obtain the SCORM schemas by downloading them from the IMS and ADL web sites or by clicking on the links in the sidebar of this page. When you click on the link, your browser will load the schema as a text file. To save it to your computer, just select "file:save" from you browser's main menu bar.<o:p></o:p></span></p> <p> <font size="3"><font face="Verdana"><span style="color: maroon; mso-bidi-font-family: Arial;"></span></font></font><br /></p> <p> <font size="3"><font face="Verdana"><span style="color: maroon; mso-bidi-font-family: Arial;">Well Formed & Valid XML</span><span style="mso-bidi-font-family: Arial;"><o:p></o:p></span></font></font></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">As mentioned, you will be preparing an xml file to describe the contents of your course to a Learning Management System or a SCORM repository. In either case, you will need to ensure that this file (imsmanifest.xml) uses the proper syntax and that it is valid.<o:p></o:p></span></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">An XML file with the proper syntax is called <strong><span style="font-family: "Arial","sans-serif";">"well-formed</span></strong>." An XML file that is well-formed and also uses the proper tags, as defined by its DTD or schemas is called "<strong><span style="font-family: "Arial","sans-serif";">valid</span></strong>." You must ensure that your manifest file is both well-formed and valid before attempting to load it into a Learning Management System, or into a SCORM repository. <o:p></o:p></span></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">If you attempt to load a course with a manifest that is not well-formed or invalid, then most likely it will fail to load, and worst of all, many learning management systems will not help identify the problems in your manifest file. Usually an error message such as "can not parse imsmanifest.xml file" is written by the LMS to your terminal. It is up to the content developer to determine why this error has occurred.<o:p></o:p></span></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">Well-Formed XML require that 1) every tag be closed, and that 2) tags do not overlap. Here is part of an imsmanifest file. Notice that the <title> tag is <strong><span style="font-family: "Arial","sans-serif";">not closed </span></strong>since it is missing a tag:


    Introduction and Usage</span></strong><br /> <strong><span style="font-family: "Arial","sans-serif";"></item></span></strong></span></b><span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;"><o:p></o:p></span></p> <p> <br /></p> <p> <span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;">The proper syntax would be:<o:p></o:p></span></p> <p> <br /></p> <p> <strong><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;"><item identifier="ITEM1" identifierref="INTRODUCTION"></span></strong><b><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;"><br /> <strong><span style="font-family: "Arial","sans-serif";">    <title>Introduction and Usage


Some XML elements convey attributes and not data. In this case, there is no need for a separate closing tag. The following statement is an example of such an element.



Although this statement is not closed by a
tag, it is a valid XML statement that might be found in a SCORM manifest file. Since this statement only has an attribute associated with it (href=filename), there is no need for a separate closing tag. These types of XML elements still require closing to be considered well formed. The closing is done by including the forward slash character "/" just before the final ">." This is required. Leaving off that forward slash is not well formed XML since the tag is not closed, and forgetting to include the forward slash will result in a XML parsing error.
Well formed XML must also have non-overlapping tags. A tag introduced after another tag must be closed before the first tag. In the following example, the tag should have been closed before the <item> tag because the <title> tag starts after the <item> tag was introduced. The <title> tag must be completely nested within the <item> tag, but in this case it <strong><span style="font-family: "Arial","sans-serif";">overlaps</span></strong>.<o:p></o:p></span></p> <p> <br /></p> <p> <strong><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;"><item identifier="ITEM1" identifierref="INTRODUCTION"></span></strong><b><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;"><br /> <strong><span style="font-family: "Arial","sans-serif";">    <title>Introduction and Usage</span></strong><br /> <strong><span style="font-family: "Arial","sans-serif";"></item></span></strong></span></b><span style="color: #666666; font-family: "Arial","sans-serif"; font-size: 9pt;"><br /> </span><strong><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;">    

Overlapping tags are not allowed in XML and, in general, will cause an exception from the LMS or SCORM repository. The correct, non-overlapping XML for the above example places the closing tag for before the closing tag for <item>.<o:p></o:p></span></p> <p> <br /></p> <p> <strong><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;"><item identifier="ITEM1" identifierref="INTRODUCTION"></span></strong><b><span style="color: #004040; font-family: "Arial","sans-serif"; font-size: 9pt;"><br /> <strong><span style="font-family: "Arial","sans-serif";">    <title>Introduction and Usage</span></strong><br /> <strong><span style="font-family: "Arial","sans-serif";">    

No comments:

Post a Comment