Method, apparatus, and device for running markup language code

By converting markup language code into scripting language code in the host and executing scripting language code on low-end terminal devices, the problem of high system resources requirements of markup language engines is solved, and rapid operation and low resource utilization are achieved on low-end devices.

CN114327494BActive Publication Date: 2025-07-01SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111613957.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2025-07-01
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

The markup language engine has high requirements for the system resources of electronic devices, which leads to low-end terminal devices such as children's watches being unable to parse and run markup language codes, and their functions are limited.

Method used

By loading and parsing markup language code in the host, converting it into script language code, and downloading the converted script language code to the target machine, and executing it using the script engine, the target machine avoids the need to parse and execute markup language code.

Benefits of technology

The converted script language code runs faster on the target machine and takes up less resources, solving the problem that low-end devices cannot run markup language code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114327494B_ABST
    Figure CN114327494B_ABST
Patent Text Reader

Abstract

Method, apparatus and medium for running markup language code. The method includes: loading source code written in a markup language; parsing the source code to generate a markup tree; converting the markup tree into script language code; downloading the script language code to a target machine so that the target machine executes the script language code using a script engine. In this method, the converted script language code runs faster and occupies fewer resources on the target machine than the markup language code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technologies, and in particular, to a method, an apparatus, and a device for running markup language code. Background Art

[0002] Since the markup language engine has high requirements for the system resources of an electronic device, such as requiring the terminal device to have RAM and CPU, for some low-end terminal devices, such as children's watches, because they do not have RAM and CPU, they cannot parse the markup language, that is, they do not have the ability to "run" markup language code, resulting in limited functions and inconvenience for subsequent development. Summary of the Invention

[0003] Embodiments of the present invention provide a method, an apparatus, and a device for running markup language code. The converted script language code runs faster and occupies fewer resources on the target machine compared to the markup language code.

[0004] In a first aspect, the present invention provides a method for running markup language code, where the method includes the following steps:

[0005] Load the source code written in the markup language; parse the source code to generate a markup tree; convert the markup tree into script language code; download the script language code to the target machine so that the target machine uses a script engine to execute the script language code.

[0006] In the embodiments of the present application, the converted script language code runs faster and occupies fewer resources on the target machine compared to the markup language code.

[0007] In a possible implementation, converting the markup tree into script language code includes:

[0008] Decompose each graphical user interface (GUI) component of the markup language corresponding to the markup tree into each GUI component of the script language based on the GUI component system of the target machine to obtain script language code.

[0009] In a possible implementation, decomposing each graphical user interface (GUI) component of the markup language corresponding to the markup tree into each GUI component of the script language based on the GUI component system of the target machine to obtain script language code includes:

[0010] Traverse and parse the markup tree constructed by the markup language;

[0011] For each markup in the markup tree, create a script language graphical user interface component;

[0012] Add the created graphical user interface components to the root document GUI component container to generate script language code;

[0013] Among them, the component is used to implement the interface and interaction functions of the tag, and provides an event listening interface, and the root document GUI component container is used to dispatch events.

[0014] In the above embodiment, the application software code written in the markup language in the target machine has a determined business logic and is fixed during installation. It does not require real-time dynamic parsing of the tag. The host machine can parse the markup language code in advance and convert it into script language code; the converted script language code runs faster and occupies less resources on the target machine than the markup language code.

[0015] In a possible implementation solution, adding the created graphical user interface component to the root document GUI component container and generating script language code includes:

[0016] When the tag tree includes an external interaction script, add the created graphical user interface component to the root document GUI component container, and generate script language code that calls the script language GUI component listening interface to register the external script.

[0017] In a possible implementation solution, the markup language is HyperText Markup Language HTML or Cascading Style Sheets CSS, and the script language is JavaScript.

[0018] In a second aspect, an embodiment of the present application further provides a device for running markup language code. The device includes modules / units that execute the method of any one of the possible designs in the first aspect above. These modules / units can be implemented by hardware or by hardware executing corresponding software.

[0019] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory. Among them, the memory is used to store one or more computer programs; when the one or more computer programs stored in the memory are executed by the processor, the electronic device can implement the method of any one of the possible designs in the first aspect above.

[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device executes the method of any one of the possible designs in any of the above aspects.

[0021] In a fifth aspect, an embodiment of the present application further provides a computer program product. When the computer program product runs on an electronic device, the electronic device executes the method of any one of the possible designs in any of the above aspects.

[0022] In a sixth aspect, an embodiment of the present application further provides a chip, which is coupled to a memory and is configured to execute a computer program stored in the memory, so that the electronic device executes the method according to any possible design in any of the above aspects.

[0023] For the beneficial effects of the above third aspect to sixth aspect, reference may be made to the description in the above first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0025] Figure 1 Schematic flowchart of a method for running markup language code provided by an embodiment of the present application;

[0026] Figure 2 Schematic flowchart of another method for running markup language code provided by an embodiment of the present application;

[0027] Figure 3 Schematic diagram of a device for running markup language code provided by an embodiment of the present application;

[0028] Figure 4 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0029] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention and make the above objects, features, and advantages of the embodiments of the present invention more obvious and understandable, the following further details the prior art solutions and the technical solutions in the embodiments of the present invention with reference to the drawings.

[0030] Currently, the markup language engine has relatively high requirements for the system resources of the target machine. To solve this problem, by introducing a host machine, the markup language code is parsed and converted into script language code, and then the conversion result is deployed to the target machine. The script language engine of the target machine executes it, and the target machine has the ability to "run" the script language code without a markup language parsing and execution engine.

[0031] An embodiment of the present application provides a schematic flowchart of a method for running markup language code, as Figure 1 shown. This method can be applied to a host machine and includes the following steps.

[0032] S101, load the source code written in the markup language.

[0033] Exemplarily, the specified storage partition of the terminal device may be the misdata partition in the flash. There is a storage interval that can be customized by the customer in this misdata partition, so it is generally not occupied by other data. When the terminal device is powered on, the file content in the specified storage partition of the terminal device is read in the download mode through a download tool; or, when the terminal device is powered on, the file content in the specified storage partition of the terminal device is read through a calibration comprehensive test tool or the terminal device software.

[0034] S102, parse the source code to generate a tag tree.

[0035] S103, convert the tag tree into script language code.

[0036] In a possible implementation manner, each graphical user interface (GUI) component of the markup language corresponding to the tag tree is decomposed into each GUI component of the script language based on the GUI component system of the target machine to obtain the script language code.

[0037] S104, download the script language code to the target.

[0038] S105, the target machine uses a script engine to execute the script language code.

[0039] The target machine can execute HTML and CSS markup language code without an HTML or CSS markup language engine.

[0040] In a specific implementation manner, combined with Figure 2 For example, the host machine performs urinalysis on the markup language source code and converts it into script language in the following way: traverse and parse the tag tree constructed by the markup language; for each tag in the tag tree, create a script language graphical user interface component; add the created graphical user interface component to the root document GUI component container to generate script language code; where the component is used to implement the interface and interaction functions of the tag and provide an event listening interface, and the root document GUI component container is used to dispatch events. Then the host machine downloads the script language code to the target machine, and the script language GUI component container in the target machine can execute the script language, so that the running speed is faster and the resource occupancy is less compared with the markup language code.

[0041] In the above method embodiments, the core functions of the markup language engine include "dynamically parse tags", "construct a memory tag data model", "draw a tag user interface", and "tag respond to user input". Since other functions except the "dynamically parse tags" function are the same as the functions of the target machine GUI system, the core functions of the markup language engine can be implemented by the script language code based on the target machine GUI system.

[0042] It can be seen that in this embodiment, the business logic of the application software code written in the markup language in the target machine is determined and fixed during installation, and there is no need to dynamically parse the markup in real time. The host machine can parse the markup language code in advance and convert it into script language code;

[0043] The converted script language code runs faster and occupies less resources on the target machine than the markup language code.

[0044] Based on the above device for running markup language code, in some embodiments of the present application, an embodiment of the present application discloses a device for running markup language code, as Figure 3 shown. The device 300 is used to implement the methods described in the above method embodiments, and it includes: a loading unit 301, a generating unit 302, a converting unit 303, and a downloading unit 304. Among them:

[0045] The loading unit 301 is used to load the source code written in the markup language.

[0046] The generating unit 302 is used to parse the source code to generate a markup tree.

[0047] The converting unit 303 is used to convert the markup tree into script language code;

[0048] The downloading unit 304 is used to download the script language code to the target machine so that the target machine can execute the script language code using a script engine.

[0049] In a possible implementation, the converting unit 303 converts the markup tree into script language code, specifically used for:

[0050] Decompose each graphical user interface (GUI) component of the markup language corresponding to the markup tree into each GUI component of the script language based on the GUI component system of the target machine to obtain the script language code.

[0051] In a possible implementation, the converting unit 303 converts the markup tree into script language code, specifically used for:

[0052] Traverse and parse the markup tree constructed by the markup language;

[0053] For each markup in the markup tree, create a script language graphical user interface component;

[0054] Add the created graphical user interface components to the root document GUI component container to generate the script language code;

[0055] Among them, the component is used to implement the interface and interaction functions of the tag and provide an event listening interface, and the root document GUI component container is used to dispatch events.

[0056] In a possible implementation solution, the generating unit 302 adds the created graphical user interface component to the root document GUI component container and generates script language code, specifically for:

[0057] When the tag tree includes an external interaction script, add the created graphical user interface component to the root document GUI component container, and generate script language code for calling the script language GUI component listening interface to register the external script.

[0058] In this embodiment, the markup language is HyperText Markup Language HTML or Cascading Style Sheets CSS, and the script language is JavaScript.

[0059] All relevant contents of each step involved in the above method embodiment can be cited to the function description of the corresponding functional module, and will not be elaborated here.

[0060] In other embodiments of the present application, embodiments of the present application disclose an electronic device, such as Figure 4 As shown, the electronic device 400 may include: one or more processors 401; a memory 402; a display 403; one or more applications (not shown); and one or more computer programs 404. The above devices may be connected through one or more communication buses 405. Among them, the one or more computer programs 404 are stored in the above memory 402 and configured to be executed by the one or more processors 401, and the one or more computer programs 404 include instructions.

[0061] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and conciseness of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the foregoing method embodiment, and will not be elaborated here.

[0062] In each embodiment of the embodiments of the present application, each functional unit may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software functional unit.

[0063] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash memory, mobile hard disks, read-only memories, random access memories, magnetic disks, or optical discs.

[0064] As described above, the above is only the specific implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of the present application should be covered by the protection scope of the embodiments of the present application. Therefore, the protection scope of the embodiments of the present application should be subject to the protection scope of the claims.

Claims

1. A method for running markup language code, applied to a host machine, characterized in that, The method includes: Loading the source code written in a markup language; Parsing the source code to generate a markup tree; Converting the markup tree into script language code, including: traversing and parsing the markup tree constructed by the markup language; for each markup in the markup tree, creating a script language graphical user interface component; adding the created graphical user interface component to the root document GUI component container to generate script language code; wherein, the component is used to implement the interface and interaction functions of the markup and provide an event listening interface, and the root document GUI component container is used to dispatch events; Downloading the script language code to a target machine so that the target machine uses a script engine to execute the script language code.

2. The method according to claim 1, wherein The adding the created graphical user interface component to the root document GUI component container to generate script language code includes: When the markup tree includes an external interaction script, adding the created graphical user interface component to the root document GUI component container to generate script language code that calls the script language GUI component listening interface to register the external script.

3. The method according to claim 1, wherein The markup language is HyperText Markup Language (HTML) or Cascading Style Sheets (CSS), and the script language is JavaScript.

4. An apparatus for running markup language code, characterized in that, The device includes: A loading unit for loading the source code written in a markup language; A generating unit for parsing the source code to generate a markup tree; A converting unit for converting the markup tree into script language code, including: traversing and parsing the markup tree constructed by the markup language; for each markup in the markup tree, creating a script language graphical user interface component; adding the created graphical user interface component to the root document GUI component container to generate script language code; wherein, the component is used to implement the interface and interaction functions of the markup and provide an event listening interface, and the root document GUI component container is used to dispatch events; A downloading unit for downloading the script language code to a target machine so that the target machine uses a script engine to execute the script language code.

5. The device according to claim 4, characterized in that, The generating unit adding the created graphical user interface component to the root document GUI component container to generate script language code is specifically used for: When the markup tree includes an external interaction script, adding the created graphical user interface component to the root document GUI component container to generate script language code that calls the script language GUI component listening interface to register the external script.

6. The device according to claim 4, characterized in that The markup language is HyperText Markup Language (HTML) or Cascading Style Sheets (CSS), and the script language is JavaScript.

7. A computer-readable storage medium storing a computer program therein, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Page data compiling method and apparatus, and page rendering method and apparatus

    CN106569824A