提交 0f8e192f 编写于 作者: G gloria

updated docs against 12206+11883+12461

Signed-off-by: Ngloria <80926032@qq.com>
上级 15869a26
# XML-to-JavaScript Conversion # @ohos.convertxml (XML-to-JavaScript Conversion)
The **convertxml** module provides APIs for converting XML text into JavaScript objects. The **convertxml** module provides APIs for converting XML text into JavaScript objects.
...@@ -36,6 +36,14 @@ Converts an XML text into a JavaScript object. ...@@ -36,6 +36,14 @@ Converts an XML text into a JavaScript object.
| ------ | ---------------------------- | | ------ | ---------------------------- |
| Object | JavaScript object.| | Object | JavaScript object.|
**Error codes**
For details about the error codes, see [Utils Error Codes](../errorcodes/errorcode-utils.md).
| ID| Error Message|
| -------- | -------- |
| 10200002 | Invalid xml string. |
**Example** **Example**
```js ```js
...@@ -46,13 +54,13 @@ let xml = ...@@ -46,13 +54,13 @@ let xml =
' <todo>Work</todo>' + ' <todo>Work</todo>' +
' <todo>Play</todo>' + ' <todo>Play</todo>' +
'</note>'; '</note>';
let conv = new convertxml.convertToJSObject(); let conv = new convertxml.ConvertXML()
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = JSON.stringify(conv.convertToJSObject(xml, options));
console.log(result); console.log(result);
// Output (non-compact) // Output (non-compact)
// {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]} // {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}
...@@ -60,14 +68,14 @@ console.log(result); ...@@ -60,14 +68,14 @@ console.log(result);
### convert<sup>(deprecated)</sup> ### convert<sup>(deprecated)</sup>
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject9+](#converttojsobject9) instead.
convert(xml: string, options?: ConvertOptions) : Object convert(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object. Converts an XML text into a JavaScript object.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [convertToJSObject<sup>9+</sup>](#converttojsobject9) instead.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Parameters** **Parameters**
......
...@@ -3,9 +3,13 @@ ...@@ -3,9 +3,13 @@
- Ability Framework - Ability Framework
- [Ability Error Codes](errorcode-ability.md) - [Ability Error Codes](errorcode-ability.md)
- [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md) - [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md)
- [Form Error Codes](errorcode-form.md)
- Bundle Management - Bundle Management
- [Bundle Error Codes](errorcode-bundle.md) - [Bundle Error Codes](errorcode-bundle.md)
- [zlib Error Codes](errorcode-zlib.md) - [zlib Error Codes](errorcode-zlib.md)
- Common Event and Notification
- [Event Error Codes](errorcode-CommonEventService.md)
- [DistributedNotificationService Error Codes](errorcode-DistributedNotificationService.md)
- UI Page - UI Page
- [promptAction Error Codes](errorcode-promptAction.md) - [promptAction Error Codes](errorcode-promptAction.md)
- [Router Error Codes](errorcode-router.md) - [Router Error Codes](errorcode-router.md)
...@@ -30,27 +34,38 @@ ...@@ -30,27 +34,38 @@
- [HUKS Error Codes](errorcode-huks.md) - [HUKS Error Codes](errorcode-huks.md)
- Data Management - Data Management
- [RDB Error Codes](errorcode-data-rdb.md) - [RDB Error Codes](errorcode-data-rdb.md)
- [Distributed KV Store Error Codes](errorcode-distributedKVStore.md)
- [Preferences Error Codes](errorcode-preferences.md) - [Preferences Error Codes](errorcode-preferences.md)
- Network Management - Network Management
- [Upload and Download Error Codes](errorcode-request.md) - [Upload and Download Error Codes](errorcode-request.md)
- Connectivity
- [NFC Error Codes](errorcode-nfc.md)
- [RPC Error Codes](errorcode-rpc.md)
- Basic Features - Basic Features
- [Accessibility Error Codes](errorcode-accessibility.md)
- [FaultLogger Error Codes](errorcode-faultlogger.md) - [FaultLogger Error Codes](errorcode-faultlogger.md)
- [Application Event Logging Error Codes](errorcode-hiappevent.md) - [Application Event Logging Error Codes](errorcode-hiappevent.md)
- [HiSysEvent Error Codes](errorcode-hisysevent.md) - [HiSysEvent Error Codes](errorcode-hisysevent.md)
- [HiDebug Error Codes](errorcode-hiviewdfx-hidebug.md) - [HiDebug Error Codes](errorcode-hiviewdfx-hidebug.md)
- [Input Method Framework Error Codes](errorcode-inputmethod-framework.md) - [Input Method Framework Error Codes](errorcode-inputmethod-framework.md)
- [Pasteboard Error Codes](errorcode-pasteboard.md) - [Pasteboard Error Codes](errorcode-pasteboard.md)
- [Screen Lock Management Error Codes](errorcode-screenlock.md)
- [Webview Error Codes](errorcode-webview.md) - [Webview Error Codes](errorcode-webview.md)
- Account Management - Account Management
- [Account Error Codes](errorcode-account.md) - [Account Error Codes](errorcode-account.md)
- [App Account Error Codes](errorcode-app-account.md) - [App Account Error Codes](errorcode-app-account.md)
- Device Management - Device Management
- [Power Consumption Statistics Error Codes](errorcode-batteryStatistics.md)
- [Brightness Error Codes](errorcode-brightness.md)
- [Power Manager Error Codes](errorcode-power.md)
- [Running Lock Error Codes](errorcode-runninglock.md)
- [Thermal Manager Error Codes](errorcode-thermal.md)
- [Device Management Error Codes](errorcode-device-manager.md) - [Device Management Error Codes](errorcode-device-manager.md)
- [Location Subsystem Error Codes](errorcode-geoLocationManager.md)
- [Screen Hopping Error Codes](errorcode-multimodalinput.md) - [Screen Hopping Error Codes](errorcode-multimodalinput.md)
- [Sensor Error Codes](errorcode-sensor.md) - [Sensor Error Codes](errorcode-sensor.md)
- [Vibrator Error Codes](errorcode-vibrator.md) - [Vibrator Error Codes](errorcode-vibrator.md)
- [System Parameter Error Codes](errorcode-system-parameterV9.md) - [System Parameter Error Codes](errorcode-system-parameterV9.md)
- [USB Error Codes](errorcode-usb.md) - [USB Error Codes](errorcode-usb.md)
- Language Base Class Library - Language Base Class Library
- [Buffer Error Codes](errorcode-buffer.md) - [Utils Error Codes](errorcode-utils.md)
- [containers Error Codes](errorcode-containers.md)
# Buffer Error Codes
## 10200001 Value Out of Range
**Error Message**
The value of ${param} is out of range.
**Description**
The value of a parameter passed in the API exceeds the valid range.
**Possible Causes**
The parameter value exceeds the value range.
**Solution**
Check and modify the parameter value.
## 10200009 Incorrect Buffer Size
**Error Message**
Buffer size must be a multiple of ${size}
**Description**
The buffer size must be an integer multiple of 16 bits, 32 bits, or 64 bits.
**Possible Causes**
The buffer size is not an integer multiple of 16 bits, 32 bits, or 64 bits.
**Solution**
Check the buffer length.
## 10200013 Read-Only Properly
**Error Message**
Cannot set property ${propertyName} of Buffer which has only a getter.
**Description**
The buffer ${propertyName} is read-only and cannot be set.
**Possible Causes**
The ${propertyName} parameter is read-only and cannot be set.
**Solution**
${propertyName} cannot be set. Do not place it on the left of the equal sign (=).
# containers Error Codes
## 10200012 Constructor Calling Failure
**Error Message**
The {className}'s constructor cannot be directly invoked.
**Description**
A constructor of the **containers** class is called directly to create an instance.
**Possible Causes**
The constructors of the **containers** class cannot be directly called. The keyword **new** must be used.
**Solution**
Use the keyword **new** to create an instance.
## 10200011 Passed this object Is Not an Instance of the containers Class
**Error Message**
The {methodName} method cannot be bound.
**Description**
**this object** passed in the API is not an instance of the **containers** class.
**Possible Causes**
The APIs of the **containers** class do not support **bind()**.
**Solution**
1. Check whether **bind()** is used to call the API.
2. Check whether an object that is not a container instance is assigned to the API.
## 10200001 Invalid Parameter Value
**Error Message**
The parameter value is out of range.
**Description**
The value of a parameter passed in the API exceeds the valid range.
**Possible Causes**
The parameter value is out of range.
**Solution**
Use a value within the range.
## 10200010 Empty Container
**Error Message**
The container is empty.
**Description**
The container to be operated is empty.
**Possible Causes**
The container is empty.
**Solution**
Add elements to the container first.
# Form Error Codes
## 16500001 Internal Error
**Error Message**
Internal Error.
**Description**
A common kernel error, for example, a malloc failure, occurs.
**Possible Causes**
The memory is insufficient.
**Solution**
Analyze the memory usage of the entire process, and check whether memory leakage occurs.
## 16500050 IPC Failure
**Error Message**
An IPC connection error happened.
**Description**
An error occurs when the system initiates inter-process communications (IPC) to complete the request.
**Possible Causes**
The parameter value passed in the API is too large, causing IPC data verification failure.
**Solution**
Pass appropriate parameter values.
## 16500060 Service Connection Failure
**Error Message**
A service connection error happened, please try again later.
**Description**
An error occurs when the system attempts to connect to a service to complete the request.
**Possible Causes**
The service is busy or abnormal.
**Solution**
Try again after the service is restarted.
## 16500100 Failed to Obtain Widget Configuration Information
**Error Message**
Failed to obtain configuration information.
**Description**
An error occurs when the system attempts to obtain widget configuration information to complete the request.
**Possible Causes**
The widget configuration information field is missing or invalid.
**Solution**
Use the correct configuration information.
## 16501000 Functional Error
**Error Message**
A functional error occurred.
**Description**
An internal error occurs when the system executes the request.
## 16501001 Widget ID Not Exist
**Error Message**
The ID of the form to be operated does not exist.
**Description**
The specified widget in the request is not found.
**Possible Causes**
The widget ID passed in the API does not exist or is invalid.
**Solution**
Use a valid widget ID.
## 16501002 Too Many Widgets
**Error Message**
The number of forms exceeds the upper bound.
**Description**
The application attempts to add more widgets when the number of widgets has reached the upper limit.
**Possible Causes**
The number of widgets has reached the upper limit.
**Solution**
Delete unnecessary widgets and then add the required widgets.
## 16501003 Widget Not Operatable
**Error Message**
The form can not be operated by the current application.
**Description**
The application cannot perform operations on a widget.
**Possible Causes**
The widget does not belong to the application.
**Solution**
1. Check the ownership of the widget ID.
2. Upgrade the application permission to **SystemApp**.
# Utils Error Codes
## 10200001 Value Out of Range
**Error Message**
The value of ${param} is out of range.
**Description**
The value of a parameter passed in the API exceeds the valid range.
**Possible Causes**
The parameter value exceeds the value range.
**Solution**
Use a valid parameter value.
## 10200002 Parameter Parsing Error
**Error Message**
Invalid ${param} string.
**Description**
Failed to parse a string.
**Possible Causes**
A parameter of the string type passed in the API is a non-standard string. As a result, the string fails to be parsed.
**Solution**
Check the format of the string.
## 10200003 Failed to Initialize the Worker Instance
**Error Message**
Worker initialization failure.
**Description**
The **Worker** instance fails to be initialized when the API is called.
**Possible Causes**
1. The number of **Worker** instances to be created exceeds the upper limit.
2. The options for setting the **Worker** instance are incorrect.
**Solution**
1. Check whether the number of **Worker** instances exceeds 8. If yes, destroy idle **Worker** instances.
2. If **WorkerOptions** is set, check the parameter type and validity.
## 10200004 Worker Instance Is Not Running
**Error Message**
Worker instance is not running.
**Description**
The **Worker** instance is not running when the API is called.
**Possible Causes**
When the API is called, the **Worker** instance has been destroyed or is being destroyed.
**Solution**
Ensure that the **Worker** instance is running properly.
## 10200005 Worker Thread Does Not Support an API
**Error Message**
The invoked API is not supported in workers.
**Description**
An API that is not supported by the worker thread is called.
**Possible Causes**
The worker thread does not support the API.
**Solution**
Use a supported API.
## 10200006 Worker Transmission Information Serialization Exception
**Error Message**
Serializing an uncaught exception failed.
**Description**
An error occurs when serializing transmission information.
**Possible Causes**
The transmission information is not serializable.
**Solution**
Use transmission information that is a valid serialized object.
## 10200007 Abnormal Worker File Path
**Error Message**
The worker file path is invalid.
**Description**
The file path is invalid, and the **Worker** instance cannot be loaded.
**Possible Causes**
The worker file path is invalid. As a result, a valid **worker.abc** file cannot be generated during the build.
**Solution**
Ensure that the worker file path complies with the specifications for creating **Worker** instances. For details, see the example under [constructor<sup>9+</sup>](../apis/js-apis-worker.md#constructor9).
## 10200009 Buffer Size Error
**Error Message**
Buffer size must be a multiple of ${size}.
**Description**
The buffer size does not meet the requirement.
**Possible Causes**
The buffer size is not an integer multiple of **size**, which can be 16-bit, 32-bit, or 64-bit.
**Solution**
Use a buffer the size of which meets the requirements.
## 10200010 Empty Container
**Error Message**
The container is empty.
**Description**
The container to be operated is empty.
**Possible Causes**
No element is added to the container.
**Solution**
Add elements to the container first.
## 10200011 Passed this.object Is Not an Instance of the containers Class
**Error Message**
The {methodName} method cannot be bound.
**Description**
**this.object** passed in the API is not an instance of the **containers** class.
**Possible Causes**
The APIs of the **containers** class do not support **bind()**.
**Solution**
1. Check whether **bind()** is used to call the API.
2. Check whether an object that is not a container instance is assigned to the API.
## 10200012 Constructor Calling Failure
**Error Message**
The {className}'s constructor cannot be directly invoked.
**Description**
A constructor of the **containers** class is called directly to create an instance.
**Possible Causes**
The constructors of the **containers** class cannot be directly called. The keyword **new** must be used.
**Solution**
Use the keyword **new** to create an instance.
## 10200013 Read-Only Properly
**Error Message**
Cannot set property ${propertyName} of Buffer which has only a getter.
**Description**
The buffer ${propertyName} is read-only and cannot be set.
**Possible Causes**
The buffer is read-only.
**Solution**
Do not set the read-only attribute for the buffer.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册