未验证 提交 aaedf601 编写于 作者: O openharmony_ci 提交者: Gitee

!3993 翻译完成:3900:API示例代码样式补充

Merge pull request !3993 from wusongqing/TR3900
# Ability Access Control
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
```
......@@ -26,7 +26,7 @@ Creates an **AtManager** instance, which is used for ability access control.
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
```
......@@ -57,7 +57,7 @@ Checks whether an application has been granted the specified permission. This AP
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......@@ -92,7 +92,7 @@ Grants a user granted permission to an application. This API uses a promise to r
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......@@ -124,7 +124,7 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
......@@ -159,7 +159,7 @@ Revokes a user granted permission given to an application. This API uses a promi
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
......@@ -190,7 +190,7 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
......@@ -223,7 +223,7 @@ Obtains the flags of the specified permission of a given application. This API u
**Example**
```
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
......
# XML-to-JavaScript Conversion
> **NOTE**
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import convertxml from '@ohos.convertxml';
```
## System Capabilities
SystemCapability.Utils.Lang
## ConvertXML
......@@ -23,61 +19,66 @@ convert(xml: string, options?: ConvertOptions) : Object
Converts an XML text into a JavaScript object.
**System capability**: SystemCapability.Utils.Lang
- Parameters
| Name| Type| Mandatory| Description|
| ------- | --------------------------------- | ---- | ------------------ |
| xml | string | Yes| XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No| Settings of the convert operation.|
**Parameters**
- Return value
| Name | Type | Mandatory| Description |
| ------- | --------------------------------- | ---- | --------------- |
| xml | string | Yes | XML text to convert.|
| options | [ConvertOptions](#convertoptions) | No | Options for coversion. |
| Type| Description|
| ------ | ---------------------------- |
| Object | JavaScript object.|
**Return value**
- Example
| Type | Description |
| ------ | ---------------------------- |
| Object | JavaScript object.|
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
```
**Example**
```js
let xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
```
## ConvertOptions
| Name| Type| Mandatory| Description|
Options for coversion.
**System capability**: SystemCapability.Utils.Lang
| Name | Type| Mandatory| Description |
| ----------------- | -------- | ---- | ----------------------------------------------------------- |
| trim | boolean | Yes| Whether to trim the whitespace characters before and after the text. The default value is **false**.|
| ignoreDeclaration | boolean | No| Whether to ignore the XML declaration. The default value is **false**.|
| ignoreInstruction | boolean | No| Whether to ignore the XML processing instruction. The default value is **false**.|
| ignoreAttributes | boolean | No| Whether to print attributes across multiple lines and indent attributes. The default value is **false**.|
| ignoreComment | boolean | No| Whether to ignore element comments. The default value is **false**.|
| ignoreCDATA | boolean | No| Whether to ignore the element's CDATA information. The default value is **false**.|
| ignoreDoctype | boolean | No| Whether to ignore the element's Doctype information. The default value is **false**.|
| ignoreText | boolean | No| Whether to ignore the element's text information. The default value is **false**.|
| declarationKey | string | Yes| Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.|
| instructionKey | string | Yes| Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.|
| attributesKey | string | Yes| Name of the attribute key for **attributes** in the output object. The default value is **_attributes**.|
| textKey | string | Yes| Name of the attribute key for **text** in the output object. The default value is **_text**.|
| cdataKey | string | Yes| Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**.|
| doctypeKey | string | Yes| Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**.|
| commentKey | string | Yes| Name of the attribute key for **comment** in the output object. The default value is **_comment**.|
| parentKey | string | Yes| Name of the attribute key for **parent** in the output object. The default value is **_parent**.|
| typeKey | string | Yes| Name of the attribute key for **type** in the output object. The default value is **_type**.|
| nameKey | string | Yes| Name of the attribute key for **name** in the output object. The default value is **_name**.|
| elementsKey | string | Yes| Name of the attribute key for **elements** in the output object. The default value is **_elements**.|
| trim | boolean | Yes | Whether to trim the whitespace characters before and after the text. The default value is **false**. |
| ignoreDeclaration | boolean | No | Whether to ignore the XML declaration. The default value is **false**. |
| ignoreInstruction | boolean | No | Whether to ignore the XML processing instruction. The default value is **false**. |
| ignoreAttributes | boolean | No | Whether to print attributes across multiple lines and indent attributes. The default value is **false**. |
| ignoreComment | boolean | No | Whether to ignore element comments. The default value is **false**. |
| ignoreCDATA | boolean | No | Whether to ignore the element's CDATA information. The default value is **false**. |
| ignoreDoctype | boolean | No | Whether to ignore the element's Doctype information. The default value is **false**. |
| ignoreText | boolean | No | Whether to ignore the element's text information. The default value is **false**. |
| declarationKey | string | Yes | Name of the attribute key for **declaration** in the output object. The default value is **_declaration**.|
| instructionKey | string | Yes | Name of the attribute key for **instruction** in the output object. The default value is **_instruction**.|
| attributesKey | string | Yes | Name of the attribute key for **attributes** in the output object. The default value is **_attributes**. |
| textKey | string | Yes | Name of the attribute key for **text** in the output object. The default value is **_text**. |
| cdataKey | string | Yes | Name of the attribute key for **CDATA** in the output object. The default value is **_cdata**. |
| doctypeKey | string | Yes | Name of the attribute key for **Doctype** in the output object. The default value is **_doctype**. |
| commentKey | string | Yes | Name of the attribute key for **comment** in the output object. The default value is **_comment**. |
| parentKey | string | Yes | Name of the attribute key for **parent** in the output object. The default value is **_parent**. |
| typeKey | string | Yes | Name of the attribute key for **type** in the output object. The default value is **_type**. |
| nameKey | string | Yes | Name of the attribute key for **name** in the output object. The default value is **_name**. |
| elementsKey | string | Yes | Name of the attribute key for **elements** in the output object. The default value is **_elements**. |
# Fault Logger
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import faultLogger from '@ohos.faultLogger'
```
......@@ -56,7 +56,7 @@ Obtains the fault information about the current process. This API uses a callbac
**Example**
```
```js
function queryFaultLogCallback(error, value) {
if (error) {
console.info('error is ' + error);
......@@ -101,7 +101,7 @@ Obtains the fault information about the current process. This API uses a promise
**Example**
```
```js
async function getLog() {
let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH);
if (value) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册