Method for converting XML Schema document into SCORM data document
By using the VTD-XML framework for XML parsing and directory structure construction, the XML SCHEMA documentation from the XML SCHEMA document to the SCORM document conversion and the large amount of calculation of the algorithm have been solved, and efficient, accurate automatic conversion and data sharing have been achieved.
Patent Information
- Application Number
- CN202411565272.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-01-21
AI Technical Summary
The existing XML conversion methods have a huge amount of manual interaction and algorithm calculation, and the division results are often not ideal, making it difficult to achieve efficient automatic conversion from XML Schema documents to SCORM documents.
By using the open source frame VTD-XML for non-extraction analysis XML files, build a directory structure information, and process the compression file through the recursive function, and finally convert the XML SCHEMA document into a scorm document.
Efficient and accurate automatic conversion is achieved, data sharing and utilization can be realized without manual participation, the application is very convenient, and SCORM data packages that comply with the S1000D standard can be generated.
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer document conversion, and in particular to a method for converting an XML Schema document into a SCORM document. Background Art
[0002] XML is a universal format for data description and exchange. It has been widely used and is universal and interchangeable. XML Schema is used to describe the structure of XML documents, constrain and validate XML documents. It also uses the XML document structure and is an alternative to DTD based on XML. XML schema defines the following parameters of XML documents: the elements and attributes that can appear in an XML document; which element is a child element; the order in which child elements appear and the number of child elements; whether an element is empty or can contain text; the data types of elements and attributes; and the default and fixed values of elements and attributes.
[0003] XSL (eXtensible Stylesheet Language) is an extensible stylesheet language, which is a language used to present XML data in a readable format. In layman's terms, XML files can be presented in different formats by referencing XSL stylesheets, that is, XSL can convert XML documents into XHTML / HTML documents or other XML documents.
[0004] Currently, the purpose of converting XML Schema documents to XSL documents is usually achieved by manually editing XML schema documents into XSL documents or using commercial software to automatically generate XSL documents from XML schema documents. However, the former is highly complex, time-consuming and labor-intensive; the latter usually requires a lot of modifications before it can be applied to XML. In addition, both methods have a serious problem: once the XML document is modified, the XSL document needs to be re-edited.
[0005] The XML conversion method is to expand the discrete points on a model into points with a radius. The distance and radius between points will generate mutual attraction and repulsion. If the interaction force is balanced, the point size and the distance between them are relatively similar, which is manifested as a uniform distribution of points. At this time, the center points of all points constitute a unit grid. Compared with the SCORM conversion method, the advantage of the XML conversion method is that its division process will continuously adjust the grid to achieve the global optimal grid structure of the final division result. However, the "homogenization" result of the XML conversion method is inconsistent with the requirements of the gradient grid. In order to achieve different grid sizes at different locations of the model and uniform gradient of the connecting parts, a large number of auxiliary points must be introduced. The auxiliary points of the conventional conversion method are introduced by manual setting or random point addition. The manual interaction and algorithm calculation are huge, and the division results are often not ideal. Summary of the invention
[0006] The purpose of the present invention is to provide a method for converting an XML Schema document into a SCORM document, so as to solve the problems that the existing XML conversion method has a huge amount of manual interaction and algorithm calculation, and the division results are often unsatisfactory.
[0007] The specific implementation method of the present invention to achieve the above object is as follows:
[0008] A method for converting an XML Schema document into a SCORM document, comprising the following steps:
[0009] Step 1: Clear the temporary directory and its subdirectories under the SCORM package directory;
[0010] Step 2: Clear the directory and its subdirectories where the XML data package is unpacked;
[0011] Step 3: Decompress the XML data packet. If the decompressed file is still a compressed file, continue to decompress it until there is no compressed file. Use a recursive function to process the existing nested compressed files.
[0012] Step 4: Get multiple data source packages after decompressing the source data package, and store the data source packages in List <publicationmodule>middle;
[0013] Step 5: Traverse the source data packets in the List to obtain the current source data packet;
[0014] Step 6: Parse the XML file in the source data package, extract the necessary data from the XML file, and construct the data structure; build the directory structure information based on the parsing results: first traverse the XML file <pmentry>label, and then for each <pmentry>Tag, create a DmCatalog object, fill in the relevant information, and finally for each DmCatalog object, check whether there is a child <pmentry>Tag, if any, recursively create a child DmCatalog object and make it a child of the current object;
[0015] Step 7: Package the data package and publish it as a SCORM data package.
[0016] Preferably, step 6 comprises:
[0017] Step 6.1: Initialize the XML file in the source data package, read and parse the PM XML file; the initialization method includes: first read the XML file content, then use the parser to convert the XML string into an operable tree structure, then set the initial conditions, and initialize any required variables or data structures;
[0018] Step 6.2: Parse the identification information and status information of the publication module data <pmstatus>, and store it in the variable currPM of type PublicationModule;
[0019] Step 6.3: Parse the XML file of the data package. If <pmentry>If the next subtag of is , then repeat parsing the source data packet until the next subtag of is ; obtain the data directory structure information and store it in the linked list List <dmcatalog>; Store the relationship between XML and SCORM into the variable pmdm of PMandDM type, and store pmdm into List.
[0020] Preferably, the step 6.3 comprises:
[0021] Step 6.3.1: Traverse the path / pm / content / pmEntry in the xml file in the PM data manual package, and create a dictionary initial_state during the traversal to store the state information during the traversal;
[0022] Step 6.3.2: Create a variable dmCatalog of the DmCatalog type for directory structure information, set the value of dmCatalog according to the information in currPM, and store dmCatalog in the linked list List;
[0023] Step 6.3.3: Parse the element tag, create a variable subDmCatalog of the directory structure information DmCatalog type, set the value of subDmCatalog according to the value of the variable dmCatalog in step (6.3.2), store subDmCatalog in the linked list List, and set the value of subDmCatalog according to the value of the first subtag;
[0024] Step 6.3.4: If the next subtag is <pmentry>, then execute step (6.3.3), if the next sub-tag of is <dmref>, then execute step (6.3.5);
[0025] Step 6.3.5: Parse the element tag, create a variable subsubDmCatalog of the directory structure information DmCatalog type, set the value of subsubDmCatalog according to the variable subDmCatalog in step (6.3.3), and store subsubDmCatalog in List;
[0026] Step 6.3.6: Parse the first subtag of the element and its subtags, get the value of DMC, and set the dmc value of subsubDmCatalog; create a variable pmdm of PMandDM type to represent the relationship between XML and SCORM, and store the variable in List;
[0027] Step 6.3.7: Get the subtag of the first subtag of an element <dmtitle>The subtag and subtag value are assigned to subsubDmCatalog.
[0028] Preferably, the step 7 comprises:
[0029] Step 7.1: Copy the imsmanifest.xml template file to the corresponding directory of the specified SCORM package;
[0030] Step 7.2: Copy other template files to the corresponding directory of the SCORM package;
[0031] Step 7.3: Set the basic information of the courseware in the imsmanifest.xml file, including the name of the SCORM package courseware, and set the properties default and identifier of organizations;
[0032] Step 7.4: Traverse the List and determine whether the node is a root node. If it is a root node, execute step (7.5); if it is not a root node, execute step (7.6);
[0033] Step 7.5: Add a child node organization to the organizations node;
[0034] Step 7.6: Find the corresponding organization according to the parent node and add the item node;
[0035] Step 7.7: Add a child node title to the newly added node organization or item;
[0036] Step 7.8: Traverse the List, copy the DMC*.xml files and the corresponding learning physics resource files under the data package to the corresponding directory of the SCORM data package, and add the relevant learning resource information to the nodes and their subnodes in the imsmanifest.xml file.
[0037] The present invention has at least the following beneficial effects:
[0038] The present invention parses multiple XML files by using the open source framework VTD-XML, which is a non-extractive XML parsing method, which better solves the disadvantage of DOM occupying too much memory, and also provides fast parsing and traversal, support for xpath and incremental update, etc. The present invention can convert XML data packets that meet the S1000D standard into complete SCORM data packets for direct use in an interactive training system (IETS), and the conversion is efficient and accurate automatic, and data sharing and utilization can be realized without human participation, so the application is very convenient. DETAILED DESCRIPTION
[0039] In order to make the purpose, method scheme and advantages of the embodiments of the present invention clearer, the method scheme in the embodiments of the present invention is clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0040] The XML standards mainly include the American standard system and the European S1000D international specification. Since S1000D uses the Data Module (DM) to organize technical information and the Common Source Database (CSDB) to manage information objects, and provides an open system description method for the development of XML, it has obvious advantages in building an integrated information environment. Therefore, the S1000D standard has become the current mainstream conversion standard in the world.
[0041] SCORM (Sharable Content Object Reference Model) was developed by the Advanced Distributed Learning (ADL) organization of the U.S. Department of Defense. It is one of the most widely used and most applicable online course standards. Its emergence makes it possible for learning resources to be reused and interoperable in different systems. A courseware that complies with the SCORM standard can be run and shared on any SCORM-compliant system.
[0042] The XML conversion method is to expand the discrete points on a model into points with a radius. The distance and radius between points will generate mutual attraction and repulsion. If the interaction force is balanced, the point size and the distance between them are relatively similar, which is manifested as a uniform distribution of points. At this time, the center points of all points constitute a unit grid. Compared with the SCORM conversion method, the advantage of the XML conversion method is that its division process will continuously adjust the grid to achieve the global optimal grid structure of the final division result. However, the "homogenization" result of the XML conversion method is inconsistent with the requirements of the gradient grid. In order to achieve different grid sizes at different locations of the model and uniform gradient of the connected parts, a large number of auxiliary points must be introduced. The auxiliary points of the conventional conversion method are introduced by manual setting or random point addition. The manual interaction and algorithm calculation are huge, and the division results are often not ideal.
[0043] In order to solve the above technical problems, the applicant has conceived the following technical solutions:
[0044] Embodiment 1: A method for converting an XML Schema document into a SCORM document, comprising the following steps:
[0045] Step 1: Clear the temporary directory and its subdirectories under the SCORM package directory;
[0046] Step 2: Clear the directory and its subdirectories where the XML data package is unpacked;
[0047] Step 3: Decompress the XML data packet. If the decompressed file is still a compressed file, continue to decompress it until there is no compressed file. Use a recursive function to process the existing nested compressed files.
[0048] Step 4: Get multiple data source packages after decompressing the source data package, and store the data source packages in List <publicationmodule>middle;
[0049] Step 5: Traverse the source data packets in the List to obtain the current source data packet;
[0050] Step 6: Parse the XML file in the source data package, extract the necessary data from the XML file, and construct the data structure; build the directory structure information based on the parsing results: first traverse the XML file <pmentry>label, and then for each <pmentry>Tag, create a DmCatalog object, fill in the relevant information, and finally for each DmCatalog object, check whether there is a child <pmentry>Tag, if any, recursively create a child DmCatalog object and make it a child of the current object;
[0051] Step 7: Package the data package and publish it as a SCORM data package.
[0052] Embodiment 2: The step 6 comprises:
[0053] Step 6.1: Initialize the XML file in the source data package, read and parse the PM XML file; the initialization method includes: first read the XML file content, then use the parser to convert the XML string into an operable tree structure, then set the initial conditions, and initialize any required variables or data structures;
[0054] Step 6.2: Parse the identification information and status information of the publication module data <pmstatus>, and store it in the variable currPM of type PublicationModule;
[0055] Step 6.3: Parse the XML file of the data package. If <pmentry>If the next subtag of is , then repeat parsing the source data packet until the next subtag of is ; obtain the data directory structure information and store it in the linked list List <dmcatalog>; Store the relationship between XML and SCORM into the variable pmdm of PMandDM type, and store pmdm into List.
[0056] Preferably, the step 6.3 comprises:
[0057] Step 6.3.1: Traverse the path / pm / content / pmEntry in the xml file in the PM data manual package, and create a dictionary initial_state during the traversal to store the state information during the traversal;
[0058] Step 6.3.2: Create a variable dmCatalog of the DmCatalog type for directory structure information, set the value of dmCatalog according to the information in currPM, and store dmCatalog in the linked list List;
[0059] Step 6.3.3: Parse the element tag, create a variable subDmCatalog of the directory structure information DmCatalog type, set the value of subDmCatalog according to the value of the variable dmCatalog in step (6.3.2), store subDmCatalog in the linked list List, and set the value of subDmCatalog according to the value of the first subtag;
[0060] Step 6.3.4: If the next subtag is <pmentry>, then execute step (6.3.3), if the next sub-tag of is <dmref>, then execute step (6.3.5);
[0061] Step 6.3.5: Parse the element tag, create a variable subsubDmCatalog of the directory structure information DmCatalog type, set the value of subsubDmCatalog according to the variable subDmCatalog in step (6.3.3), and store subsubDmCatalog in List;
[0062] Step 6.3.6: Parse the first subtag of the element and its subtags, get the value of DMC, and set the dmc value of subsubDmCatalog; create a variable pmdm of PMandDM type to represent the relationship between XML and SCORM, and store the variable in List;
[0063] Step 6.3.7: Get the subtag of the first subtag of an element <dmtitle>The subtag and subtag value are assigned to subsubDmCatalog.
[0064] Embodiment 3: The step 7 comprises:
[0065] Step 7.1: Copy the imsmanifest.xml template file to the corresponding directory of the specified SCORM package;
[0066] Step 7.2: Copy other template files to the corresponding directory of the SCORM package;
[0067] Step 7.3: Set the basic information of the courseware in the imsmanifest.xml file, including the name of the SCORM package courseware, and set the properties default and identifier of organizations;
[0068] Step 7.4: Traverse the List and determine whether the node is a root node. If it is a root node, execute step (7.5); if it is not a root node, execute step (7.6);
[0069] Step 7.5: Add a child node organization to the organizations node;
[0070] Step 7.6: Find the corresponding organization according to the parent node and add the item node;
[0071] Step 7.7: Add a child node title to the newly added node organization or item;
[0072] Step 7.8: Traverse the List, copy the DMC*.xml files and the corresponding learning physics resource files under the data package to the corresponding directory of the SCORM data package, and add the relevant learning resource information to the nodes and their subnodes in the imsmanifest.xml file.
[0073] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.< / dmtitle> < / dmref> < / pmentry> < / dmcatalog> < / pmentry> < / pmstatus> < / pmentry> < / pmentry> < / pmentry> < / publicationmodule> < / dmtitle> < / dmref> < / pmentry> < / dmcatalog> < / pmentry> < / pmstatus> < / pmentry> < / pmentry> < / pmentry> < / publicationmodule>
Claims
1. A method for converting an XML Schema document into a SCORM document, characterized in that: The following steps are involved: Step 1: Clear the temporary directory and its subdirectories under the SCORM package directory; Step 2: Clear the directory and its subdirectories where the XML data package is unpacked; Step 3: Decompress the XML data packet. If the decompressed file is still a compressed file, continue to decompress it until there is no compressed file. Use a recursive function to process the existing nested compressed files. Step 4: Get multiple data source packages after decompressing the source data package, and store the data source packages in List <publicationmodule> middle;< / publicationmodule> Step 5: Traverse the source data packets in the List to obtain the current source data packet; Step 6: Parse the XML file in the source data package, extract the necessary data from the XML file, and construct the data structure; build the directory structure information based on the parsing results: first traverse the XML file <pmentry>label, and then for each <pmentry>Tag, create a DmCatalog object, fill in the relevant information, and finally for each DmCatalog object, check whether there is a child <pmentry> Tag, if any, recursively create a child DmCatalog object and make it a child of the current object;< / pmentry> < / pmentry> < / pmentry> Step 7: Package the data package and publish it as a SCORM data package.
2. The method for converting an XML Schema document into a SCORM document according to claim 1, characterized in that: The step 6 comprises: Step 6.1: Initialize the XML file in the source data package, read and parse the PM XML file; the initialization method includes: first read the XML file content, then use the parser to convert the XML string into an operable tree structure, then set the initial conditions, and initialize any required variables or data structures; Step 6.2: Parse the identification information and status information of the publication module data <pmstatus> , and store it in the variable currPM of type PublicationModule;< / pmstatus> Step 6.3: Parse the XML file of the data package. If <pmentry>If the next subtag of is , then repeat parsing the source data packet until the next subtag of is ; obtain the data directory structure information and store it in the linked list List <dmcatalog> ; Store the relationship between XML and SCORM into the variable pmdm of PMandDM type, and store pmdm into List.< / dmcatalog> < / pmentry> 3. The method for converting an XML Schema document into a SCORM document according to claim 2, characterized in that: The step 6.3 comprises: Step 6.3.1: Traverse the path / pm / content / pmEntry in the xml file in the PM data manual package, and create a dictionary initial_state during the traversal to store the state information during the traversal; Step 6.3.2: Create a variable dmCatalog of the DmCatalog type for directory structure information, set the value of dmCatalog according to the information in currPM, and store dmCatalog in the linked list List; Step 6.3.3: Parse the element tag, create a variable subDmCatalog of the directory structure information DmCatalog type, set the value of subDmCatalog according to the value of the variable dmCatalog in step (6.3.2), store subDmCatalog in the linked list List, and set the value of subDmCatalog according to the value of the first subtag; Step 6.3.4: If the next subtag is <pmentry>, then execute step (6.3.3), if the next sub-tag of is <dmref> , then execute step (6.3.5);< / dmref> < / pmentry> Step 6.3.5: Parse the element tag, create a variable subsubDmCatalog of the directory structure information DmCatalog type, set the value of subsubDmCatalog according to the variable subDmCatalog in step (6.3.3), and store subsubDmCatalog in List; Step 6.3.6: Parse the first subtag of the element and its subtags, get the value of DMC, and set the dmc value of subsubDmCatalog; create a variable pmdm of PMandDM type to represent the relationship between XML and SCORM, and store the variable in List; Step 6.3.7: Get the subtag of the first subtag of an element <dmtitle>The subtag and subtag value are assigned to subsubDmCatalog.< / dmtitle> 4. The method for converting an XML Schema document into a SCORM document according to claim 1, characterized in that: The step 7 comprises: Step 7.1: Copy the imsmanifest.xml template file to the corresponding directory of the specified SCORM package; Step 7.2: Copy other template files to the corresponding directory of the SCORM package; Step 7.3: Set the basic information of the courseware in the imsmanifest.xml file, including the name of the SCORM package courseware, and set the properties default and identifier of organizations; Step 7.4: Traverse the List and determine whether the node is a root node. If it is a root node, execute step (7.5); if it is not a root node, execute step (7.6); Step 7.5: Add a child node organization to the organizations node; Step 7.6: Find the corresponding organization according to the parent node and add the item node; Step 7.7: Add a child node title to the newly added node organization or item; Step 7.8: Traverse the List, copy the DMC*.xml files and the corresponding learning physics resource files under the data package to the corresponding directory of the SCORM data package, and add the relevant learning resource information to the nodes and their subnodes in the imsmanifest.xml file.