提交 ab7ed359 编写于 作者: G Gloria

Update docs against 11917+11936

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 0ed48d81
# XML Parsing and Generation # @ohos.xml (XML Parsing and Generation)
> **NOTE** > **NOTE**
> >
...@@ -24,10 +24,10 @@ A constructor used to create an **XmlSerializer** instance. ...@@ -24,10 +24,10 @@ A constructor used to create an **XmlSerializer** instance.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | -------- | --------------------------------- | ---- | ------------------------------------------------ |
| buffer | ArrayBuffer&nbsp;\|&nbsp;DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.| | buffer | ArrayBuffer \| DataView | Yes | **ArrayBuffer** or **DataView** for storing the XML information to write.|
| encoding | string | No| Encoding format.| | encoding | string | No | Encoding format. |
**Example** **Example**
...@@ -48,10 +48,10 @@ Sets an attribute. ...@@ -48,10 +48,10 @@ Sets an attribute.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | --------------- |
| name | string | Yes| Key of the attribute.| | name | string | Yes | Key of the attribute. |
| value | string | Yes| Value of the attribute.| | value | string | Yes | Value of the attribute.|
**Example** **Example**
...@@ -60,8 +60,8 @@ let arrayBuffer = new ArrayBuffer(1024); ...@@ -60,8 +60,8 @@ let arrayBuffer = new ArrayBuffer(1024);
let bufView = new DataView(arrayBuffer); let bufView = new DataView(arrayBuffer);
let thatSer = new xml.XmlSerializer(bufView); let thatSer = new xml.XmlSerializer(bufView);
thatSer.startElement("note"); thatSer.startElement("note");
thatSer.setAttributes("importance", "high"); thatSer.setAttributes("importance", "high");
thatSer.endElement(); thatSer.endElement();
``` ```
...@@ -75,9 +75,9 @@ Adds an empty element. ...@@ -75,9 +75,9 @@ Adds an empty element.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ------------------ |
| name | string | Yes| Name of the empty element to add.| | name | string | Yes | Name of the empty element to add.|
**Example** **Example**
...@@ -117,9 +117,9 @@ Writes the start tag based on the given element name. ...@@ -117,9 +117,9 @@ Writes the start tag based on the given element name.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ------------------ |
| name | string | Yes| Name of the element.| | name | string | Yes | Name of the element.|
**Example** **Example**
...@@ -145,11 +145,11 @@ Writes the end tag of the element. ...@@ -145,11 +145,11 @@ Writes the end tag of the element.
let arrayBuffer = new ArrayBuffer(1024); let arrayBuffer = new ArrayBuffer(1024);
let bufView = new DataView(arrayBuffer); let bufView = new DataView(arrayBuffer);
let thatSer = new xml.XmlSerializer(bufView); let thatSer = new xml.XmlSerializer(bufView);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.setNamespace("h", "https://www.w3.org/TR/html4/");
thatSer.startElement("table"); thatSer.startElement("table");
thatSer.setAttributes("importance", "high"); thatSer.setAttributes("importance", "high");
thatSer.setText("Happy"); thatSer.setText("Happy");
thatSer.endElement(); // => <h:table importance="high" xmlns:h="http://www.w3.org/TR/html4/">Happy</h:table> thatSer.endElement(); // => <h:table importance="high" xmlns:h="https://www.w3.org/TR/html4/">Happy</h:table>
``` ```
...@@ -163,10 +163,10 @@ Sets the namespace for an element tag. ...@@ -163,10 +163,10 @@ Sets the namespace for an element tag.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | --------- | ------ | ---- | ------------------------------ |
| prefix | string | Yes| Prefix of the element and its child elements.| | prefix | string | Yes | Prefix of the element and its child elements. |
| namespace | string | Yes| Namespace to set.| | namespace | string | Yes | Namespace to set.|
**Example** **Example**
...@@ -174,9 +174,9 @@ Sets the namespace for an element tag. ...@@ -174,9 +174,9 @@ Sets the namespace for an element tag.
let arrayBuffer = new ArrayBuffer(1024); let arrayBuffer = new ArrayBuffer(1024);
let thatSer = new xml.XmlSerializer(arrayBuffer); let thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration(); thatSer.setDeclaration();
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.setNamespace("h", "https://www.w3.org/TR/html4/");
thatSer.startElement("note"); thatSer.startElement("note");
thatSer.endElement();// = >'<?xml version="1.0" encoding="utf-8"?>\r\n<h:note xmlns:h="http://www.w3.org/TR/html4/"/>'; thatSer.endElement();// = >'<?xml version="1.0" encoding="utf-8"?>\r\n<h:note xmlns:h="https://www.w3.org/TR/html4/"/>';
``` ```
### setComment ### setComment
...@@ -189,9 +189,9 @@ Sets the comment. ...@@ -189,9 +189,9 @@ Sets the comment.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | -------------------- |
| text | string | Yes| Comment to set.| | text | string | Yes | Comment to set.|
**Example** **Example**
...@@ -214,9 +214,9 @@ Sets CDATA attributes. ...@@ -214,9 +214,9 @@ Sets CDATA attributes.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ----------------- |
| text | string | Yes| CDATA attribute to set.| | text | string | Yes | CDATA attribute to set.|
**Example** **Example**
...@@ -237,9 +237,9 @@ Sets **Text**. ...@@ -237,9 +237,9 @@ Sets **Text**.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------- |
| text | string | Yes| Content of the **Text** to set.| | text | string | Yes | Content of the **Text** to set.|
**Example** **Example**
...@@ -263,9 +263,9 @@ Sets **DocType**. ...@@ -263,9 +263,9 @@ Sets **DocType**.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ------------------- |
| text | string | Yes| Content of **DocType** to set.| | text | string | Yes | Content of **DocType** to set.|
**Example** **Example**
...@@ -289,10 +289,10 @@ Creates and returns an **XmlPullParser** object. The **XmlPullParser** object pa ...@@ -289,10 +289,10 @@ Creates and returns an **XmlPullParser** object. The **XmlPullParser** object pa
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | -------- | --------------------------------- | ---- | ------------------------------------------ |
| buffer | ArrayBuffer&nbsp;\|&nbsp;DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.| | buffer | ArrayBuffer \| DataView | Yes | **ArrayBuffer** or **DataView** that contains XML text information.|
| encoding | string | No| Encoding format. Only UTF-8 is supported.| | encoding | string | No | Encoding format. Only UTF-8 is supported. |
**Example** **Example**
...@@ -324,9 +324,9 @@ Parses XML information. ...@@ -324,9 +324,9 @@ Parses XML information.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------ | ----------------------------- | ---- | -------------------------------- |
| option | [ParseOptions](#parseoptions) | Yes| Options for controlling and obtaining the parsed information.| | option | [ParseOptions](#parseoptions) | Yes | Options for controlling and obtaining the parsed information.|
**Example** **Example**
...@@ -372,13 +372,13 @@ Defines the XML parsing options. ...@@ -372,13 +372,13 @@ Defines the XML parsing options.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
| Name| Type| Mandatory| Description| | Name | Type | Mandatory| Description |
| -------- | -------- | -------- | -------- | | ------------------------------ | ------------------------------------------------------------ | ---- | --------------------------------------- |
| supportDoctype | boolean | No| Whether to ignore **Doctype**. The default value is **false**.| | supportDoctype | boolean | No | Whether to ignore **Doctype**. The default value is **false**.|
| ignoreNameSpace | boolean | No| Whether to ignore **Namespace**. The default value is **false**.| | ignoreNameSpace | boolean | No | Whether to ignore **Namespace**. The default value is **false**. |
| tagValueCallbackFunction | (name:&nbsp;string,&nbsp;value:&nbsp;string)=&gt;&nbsp;boolean | No| Callback used to return **tagValue**.| | tagValueCallbackFunction | (name: string, value: string) =&gt; boolean | No | Callback used to return **tagValue**. |
| attributeValueCallbackFunction | (name:&nbsp;string,&nbsp;value:&nbsp;string)=&gt;&nbsp;boolean | No| Callback used to return **attributeValue**.| | attributeValueCallbackFunction | (name: string, value: string) =&gt; boolean | No | Callback used to return **attributeValue**. |
| tokenValueCallbackFunction | (eventType:&nbsp;[EventType](#eventtype),&nbsp;value:&nbsp;[ParseInfo](#parseinfo))=&gt;&nbsp;boolean | No| Callback used to return **tokenValue**.| | tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo)) =&gt; boolean | No | Callback used to return **tokenValue**. |
## ParseInfo ## ParseInfo
...@@ -395,8 +395,8 @@ Obtains the column line number, starting from 1. ...@@ -395,8 +395,8 @@ Obtains the column line number, starting from 1.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | -------------- |
| number | Column number obtained.| | number | Column number obtained.|
...@@ -410,8 +410,8 @@ Obtains the depth of this element. ...@@ -410,8 +410,8 @@ Obtains the depth of this element.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | -------------------- |
| number | Depth obtained.| | number | Depth obtained.|
...@@ -425,8 +425,8 @@ Obtains the current line number, starting from 1. ...@@ -425,8 +425,8 @@ Obtains the current line number, starting from 1.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | -------------- |
| number | Line number obtained.| | number | Line number obtained.|
...@@ -440,8 +440,8 @@ Obtains the name of this element. ...@@ -440,8 +440,8 @@ Obtains the name of this element.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------ |
| string | Element name obtained.| | string | Element name obtained.|
...@@ -455,8 +455,8 @@ Obtains the namespace of this element. ...@@ -455,8 +455,8 @@ Obtains the namespace of this element.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------------ |
| string | Namespace obtained.| | string | Namespace obtained.|
...@@ -470,8 +470,8 @@ Obtains the prefix of this element. ...@@ -470,8 +470,8 @@ Obtains the prefix of this element.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------ |
| string | Element prefix obtained.| | string | Element prefix obtained.|
...@@ -485,8 +485,8 @@ Obtains the text of the current event. ...@@ -485,8 +485,8 @@ Obtains the text of the current event.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ------------------------ |
| string | Text content obtained.| | string | Text content obtained.|
...@@ -500,8 +500,8 @@ Checks whether the current element is empty. ...@@ -500,8 +500,8 @@ Checks whether the current element is empty.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | ---------------------------- |
| boolean | Returns **true** if the element is empty; returns **false** otherwise.| | boolean | Returns **true** if the element is empty; returns **false** otherwise.|
...@@ -515,8 +515,8 @@ Checks whether the current text event contains only whitespace characters. ...@@ -515,8 +515,8 @@ Checks whether the current text event contains only whitespace characters.
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------- | -------------------------------------- |
| boolean | Returns **true** if the text event contains only whitespace characters; returns **false** otherwise.| | boolean | Returns **true** if the text event contains only whitespace characters; returns **false** otherwise.|
...@@ -529,8 +529,8 @@ Obtains the number of attributes for the current start tag. ...@@ -529,8 +529,8 @@ Obtains the number of attributes for the current start tag.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ------ | ---------------------- |
| number | Number of attributes obtained.| | number | Number of attributes obtained.|
...@@ -540,16 +540,16 @@ Enumerates the events. ...@@ -540,16 +540,16 @@ Enumerates the events.
**System capability**: SystemCapability.Utils.Lang **System capability**: SystemCapability.Utils.Lang
| Name| Value| Description| | Name | Value | Description |
| -------- | -------- | -------- | | ---------------- | ---- | --------------------- |
| START_DOCUMENT | 0 | Indicates a start document event.| | START_DOCUMENT | 0 | Indicates a start document event. |
| END_DOCUMENT | 1 | Indicates an end document event.| | END_DOCUMENT | 1 | Indicates an end document event. |
| START_TAG | 2 | Indicates a start tag event.| | START_TAG | 2 | Indicates a start tag event. |
| END_TAG | 3 | Indicates an end tag event.| | END_TAG | 3 | Indicates an end tag event. |
| TEXT | 4 | Indicates a text event.| | TEXT | 4 | Indicates a text event. |
| CDSECT | 5 | Indicates a CDATA section event.| | CDSECT | 5 | Indicates a CDATA section event. |
| COMMENT | 6 | Indicates an XML comment event.| | COMMENT | 6 | Indicates an XML comment event. |
| DOCDECL | 7 | Indicates an XML document type declaration event.| | DOCDECL | 7 | Indicates an XML document type declaration event.|
| INSTRUCTION | 8 | Indicates an XML processing instruction event.| | INSTRUCTION | 8 | Indicates an XML processing instruction event.|
| ENTITY_REFERENCE | 9 | Indicates an entity reference event.| | ENTITY_REFERENCE | 9 | Indicates an entity reference event. |
| WHITESPACE | 10 | Indicates a whitespace character event.| | WHITESPACE | 10 | Indicates a whitespace character event. |
...@@ -25,6 +25,9 @@ Develop, review, and test code following the OpenHarmony coding standards. Make ...@@ -25,6 +25,9 @@ Develop, review, and test code following the OpenHarmony coding standards. Make
### Introducing Open-source Software ### Introducing Open-source Software
For details, see [Introducing Open-Source Software](introducing-open-source-software.md). For details, see [Introducing Open-Source Software](introducing-open-source-software.md).
### Test Guide
[OpenHarmony Secure Test Guide](OpenHarmony-security-test-guide.md)
## Contribution Workflow ## Contribution Workflow
...@@ -32,7 +35,10 @@ For details, see [Contribution Process](contribution-process.md). ...@@ -32,7 +35,10 @@ For details, see [Contribution Process](contribution-process.md).
## Security Issue Disclosure ## Security Issue Disclosure
- [OpenHarmony Security Vulnerability Governance](https://gitee.com/openharmony/security/blob/master/en/security-process/README.md) - [OpenHarmony Security Vulnerability Governance](https://gitee.com/openharmony/security/blob/master/en/security-process/README.md)
- [OpenHarmony Security and Disclosure Statement](https://gitee.com/openharmony/security/blob/master/en/security-process/security-disclosure.md)
- [OpenHarmony Security and Disclosure Statement](https://gitee.com/openharmony/security/blob/master/en/security-process/security-disclosure.md)
<!--no_check-->
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册