From 173065dc08a2f455122f23ab8a79f0d5d4097225 Mon Sep 17 00:00:00 2001 From: lihucheng Date: Thu, 20 Jan 2022 11:35:04 +0800 Subject: [PATCH 1/2] Signed-off-by: lihucheng On branch OpenHarmony-3.1-Beta Your branch is up to date with 'origin/OpenHarmony-3.1-Beta'. --- api/@ohos.convertxml.d.ts | 154 ++++++++++++++++++++++++++++++++ api/@ohos.xml.d.ts | 181 ++++++++++---------------------------- 2 files changed, 201 insertions(+), 134 deletions(-) create mode 100644 api/@ohos.convertxml.d.ts diff --git a/api/@ohos.convertxml.d.ts b/api/@ohos.convertxml.d.ts new file mode 100644 index 0000000000..05574ba3fb --- /dev/null +++ b/api/@ohos.convertxml.d.ts @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The convertxml module provides utilities for converting XML text to Javascript object. + * @since 8 + * @sysCap SystemCapability.CCRuntime + * @devices phone, tablet + * @import import convertXml from '@ohos.convertxml'; + * @permission N/A + */ +declare namespace xml { + interface ConvertOptions { + /** + * Whether to trim whitespace characters that may exist before and after the text, default false. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + trim: boolean; + /** + * Whether to ignore writing declaration directives of xml. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreDeclaration?: boolean; + /** + * Whether to ignore writing processing instruction of xml. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreInstruction?: boolean; + /** + * Whether to print attributes across multiple lines and indent them. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreAttributes?: boolean; + /** + * Whether to ignore writing comments of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreComment?: boolean; + /** + * Whether to ignore writing CData of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreCdata?: boolean; + /** + * Whether to ignore writing Doctype of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreDoctype?: boolean; + /** + * Whether to ignore writing texts of the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + ignoreText?: boolean; + /** + * Name of the property key which will be used for the declaration. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + declarationKey: string; + /** + * Name of the property key which will be used for the processing instruction. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + instructionKey: string; + /** + * Name of the property key which will be used for the attributes. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + attributesKey: string; + /** + * Name of the property key which will be used for the text. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + textKey: string; + /** + * Name of the property key which will be used for the cdata. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + cdataKey: string; + /** + * Name of the property key which will be used for the doctype. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + doctypeKey: string; + /** + * Name of the property key which will be used for the comment. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + commentKey: string; + /** + * Name of the property key which will be used for the parent. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + parentKey: string; + /** + * Name of the property key which will be used for the type. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + typeKey: string; + /** + * Name of the property key which will be used for the name. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + nameKey: string; + /** + * Name of the property key which will be used for the elements. + * @since 8 + * @sysCap SystemCapability.CCRuntime + */ + elementsKey: string; + } + + interface ConvertXML { + /** + * To convert XML text to JavaScript object. + * @since 8 + * @sysCap SystemCapability.CCRuntime. + * @param xml The xml text to be converted. + * @param option Option Inputted by user to set. + * @return Returns a JavaScript object converting from XML text. + */ + convert(xml: string, options?: ConvertOptions) : Object; + } +} +export default xml; \ No newline at end of file diff --git a/api/@ohos.xml.d.ts b/api/@ohos.xml.d.ts index 33237bc5ec..8d55d7a9c7 100644 --- a/api/@ohos.xml.d.ts +++ b/api/@ohos.xml.d.ts @@ -22,135 +22,6 @@ * @permission N/A */ declare namespace xml { - interface ConvertOptions { - /** - * Whether to trim whitespace characters that may exist before and after the text, default false. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - trim: boolean; - /** - * Whether to ignore writing declaration directives of xml. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreDeclaration?: boolean; - /** - * Whether to ignore writing processing instruction of xml. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreInstruction?: boolean; - /** - * Whether to print attributes across multiple lines and indent them. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreAttributes?: boolean; - /** - * Whether to ignore writing comments of the elements. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreComment?: boolean; - /** - * Whether to ignore writing CData of the elements. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreCdata?: boolean; - /** - * Whether to ignore writing Doctype of the elements. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreDoctype?: boolean; - /** - * Whether to ignore writing texts of the elements. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - ignoreText?: boolean; - /** - * Name of the property key which will be used for the declaration. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - declarationKey: string; - /** - * Name of the property key which will be used for the processing instruction. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - instructionKey: string; - /** - * Name of the property key which will be used for the attributes. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - attributesKey: string; - /** - * Name of the property key which will be used for the text. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - textKey: string; - /** - * Name of the property key which will be used for the cdata. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - cdataKey: string; - /** - * Name of the property key which will be used for the doctype. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - doctypeKey: string; - /** - * Name of the property key which will be used for the comment. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - commentKey: string; - /** - * Name of the property key which will be used for the parent. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - parentKey: string; - /** - * Name of the property key which will be used for the type. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - typeKey: string; - /** - * Name of the property key which will be used for the name. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - nameKey: string; - /** - * Name of the property key which will be used for the elements. - * @since 8 - * @sysCap SystemCapability.CCRuntime - */ - elementsKey: string; - } - - interface ConvertXML { - /** - * To convert XML text to JavaScript object. - * @since 8 - * @sysCap SystemCapability.CCRuntime. - * @param xml The xml text to be converted. - * @param option Option Inputted by user to set. - * @return Returns a JavaScript object converting from XML text. - */ - convert(xml: string, options?: ConvertOptions) : Object; - } - class XmlSerializer { /** * A parameterized constructor used to create a new XmlSerializer instance. @@ -246,90 +117,132 @@ declare namespace xml { enum EventType { /** * Start a document. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ START_DOCUMENT, /** * End a document. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ END_DOCUMENT, /** * Start a tag. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ START_TAG, /** * End a tag. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ END_TAG, /** * Character data. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ TEXT, /** * A CDATA sections. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ CDSECT, /** * An XML comment. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ COMMENT, /** * An XML document type declaration. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ DOCDECL, /** * An XML processing instruction declaration. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ INSTRUCTION, /** * An entity reference. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ ENTITY_REFERENCE, /** * a whitespace. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ - WHITESPACE, + WHITESPACE } /** The current parse info. */ interface ParseInfo { /** * The current column number, starting from 1. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getColumnNumber(): number; /** * The current depth of the element. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getDepth(): number; /** - * The current column number, starting from 1. + * The current line number, starting from 1. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getLineNumber(): number; /** - * The current element name. + * The current element's name. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getName(): string; /** - * The current element's name. + * The current element's namespace. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getNamespace(): string; /** - * The current element's namespace. + * The current element's prefix. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getPrefix(): string; /** * The text content of the current event as String. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getText(): string; /** * Returns true if the current element is empty. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ isEmptyElementTag(): boolean; /** * Checks whether the current TEXT event contains only whitespace characters. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ isWhitespace(): boolean; /** * Returns the number of attributes of the current start tag. + * @since 8 + * @sysCap SystemCapability.CCRuntime */ getAttributeCount(): number; } -- Gitee From 0b435b734c2b03102c01a0f97b5b9c70bfab9563 Mon Sep 17 00:00:00 2001 From: lihucheng Date: Mon, 24 Jan 2022 22:59:44 +0800 Subject: [PATCH 2/2] Signed-off-by: lihucheng On branch OpenHarmony-3.1-Beta Your branch is up to date with 'origin/OpenHarmony-3.1-Beta'. --- api/@ohos.convertxml.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.convertxml.d.ts b/api/@ohos.convertxml.d.ts index 05574ba3fb..7dc0261c6f 100644 --- a/api/@ohos.convertxml.d.ts +++ b/api/@ohos.convertxml.d.ts @@ -139,7 +139,7 @@ declare namespace xml { elementsKey: string; } - interface ConvertXML { + class ConvertXML { /** * To convert XML text to JavaScript object. * @since 8 -- Gitee