@a-mehrabi/aranode-amqp-client 中文文档教程
XML PARSER Module
aranode 流引擎的 xml 解析器实现。
Table of Contents
Installation
要在您的 aranode 项目中安装此模块, 你只需要使用以下命令添加包:
$ yarn add @a-mehrabi/aranode-xml-parser
之后,当你想使用它时, 您必须将其包含在自定义模块中,如下所示:
path: .env
ARANODE_CUSTOM_MODULES=@a-mehrabi/aranode-xml-parser
Usage
要使用 xml 编码器或解码器,您需要使用编码器或解码器相关描述:
- xml encoder flow description (xmlEncoder)
- xml decoder flow description (xmlDecoder)
xml encoder
xml encoder flow description使您能够将 xml 编码器定义为流节点,包括缩进、noArrayIndent 配置等。
xml 编码器,将 javascript 文字对象编码为 xml 字符串。
version: 1
kind: flow
name: flow-name
entryPoint: start
flow:
start:
transform:
path: 'dist/get-payload-transformer.js'
nextNode: initXmlEncoder
initXmlEncoder:
xmlEncoder:
headless: false
nextNode: checkPayload
checkPayload:
transform:
path: 'dist/check-payload-transformer.js'
terminal: true
xml decoder
xml 解码器流描述使您能够将 xml 解码器定义为流节点。
xml 解码器,将 xml 字符串解码为 javascript 文字对象。
version: 1
kind: flow
name: flow-name
entryPoint: start
flow:
start:
transform:
path: 'dist/get-payload-transformer.js'
nextNode: initXmlDecoder
initXmlDecoder:
xmlDecoder:
explicitCharkey: false
nextNode: checkPayload
checkPayload:
transform:
path: 'dist/check-payload-transformer.js'
terminal: true
API
xmlEncoder
类型:流程描述
选项:
attrkey(字符串),可选,默认值 = '$'
用于访问属性的前缀。
charkey (string),可选,默认= '_'
用于访问字符内容的前缀。
rootName(字符串),
在 explicitRoot 为 false 时使用的可选根元素名称 或覆盖根元素名称。 (默认根或根键名称)
doctype(任意),可选,默认 = null
可选 DTD。 例如。 {'分机':'你好.dtd'}。
headless(布尔值),可选,默认值 = false
省略 XML 标头。
allowSurrogateChars(布尔值),可选,默认值 = false
允许使用来自 Unicode 代理项块的字符。
cdata (boolean), optional, default = false
在 中包裹文本节点,而不是在必要时转义。 如果不需要,则不添加 。
xmllDecoder
类型:流程描述
选项:
key(字符串),可选
attrkey(字符串),可选,默认 = '$'
用于访问属性的前缀。
charkey (string),可选,默认= '_'
用于访问字符内容的前缀。
explicitCharkey (boolean),可选,默认 = false
trim (boolean),可选,default = false
修剪文本节点开头和结尾的空白。
normalizeTags(布尔值),可选,默认 = false
将所有标签名称规范化为小写。
normalize(布尔值),可选,默认 = false
修剪文本节点内的空格。
explicitRoot (boolean), optional, default = true
如果你想得到结果对象中的根节点,设置这个。
explicitArray (boolean), optional, default = true
如果为真,则始终将子节点放入数组中; 否则,仅当存在多个时才创建一个数组。
ignoreAttrs (boolean), optional, default = false
忽略所有 XML 属性,只创建文本节点。
mergeAttrs (boolean), optional, default = false
合并属性和子元素作为父元素的属性,
而不是关闭子属性对象的键控属性。
如果 ignoreAttrs 为真,则忽略此选项。xmlns (boolean), optional, default = false
给每个元素一个字段,通常叫做'$ns'(第一个字符和attrkey一样)
包含其本地名称和名称空间 URI。explicitChildren (boolean), optional, default = false
将子元素放在单独的属性中。 不适用于 mergeAttrs = true。
如果元素没有子元素,则不会创建“子元素”。childkey(字符串),可选,默认值 = '$$'
如果 explicitChildren 设置为 true,则用于访问子元素的前缀。
preserveChildrenOrder(布尔值),可选,默认值 = false
修改 explicitChildren 的行为,以便“children”属性的值成为有序数组。
如果为真,每个节点还将获得一个#name 字段,其值将对应于 XML nodeName,
这样您就可以迭代“children”数组并且仍然能够确定节点名称。
命名(并且可能无序)属性也保留在此配置中,与有序的“子”数组处于同一级别。charsAsChildren(布尔值),可选,默认值 = false
如果 explicitChildren 打开,则确定字符是否应被视为子项。
includeWhiteChars(布尔值),可选,默认值 = false
确定是否应包含纯空白文本节点。
async (boolean), optional, default = false
回调应该是异步的吗? 如果您的代码依赖于回调的同步执行,这可能是一个不兼容的更改。
xml2js 的未来版本可能会更改此默认值,因此建议无论如何不要依赖于同步执行。strict (boolean), optional, default = true
设置sax-js为严格或非严格解析模式。
强烈推荐默认为 true,
因为解析格式不正确的 XML 的 HTML 可能会产生任何结果。chunkSize(数字),可选
XML PARSER Module
xml parser implementation for aranode flow engine.
Table of Contents
Installation
To install this module in your aranode project, you just need to add the package using following command:
$ yarn add @a-mehrabi/aranode-xml-parser
After that, when you want to use it, you must include it in custom modules like the following:
path: .env
ARANODE_CUSTOM_MODULES=@a-mehrabi/aranode-xml-parser
Usage
For using xml encoder or decoder, you need to use encoder or decoder associated description:
- xml encoder flow description (xmlEncoder)
- xml decoder flow description (xmlDecoder)
xml encoder
xml encoder flow description enables you to define the xml encoder as a flow node, including indent, noArrayIndent config, etc.
xml encoder, encodes javascript literal object to xml string.
version: 1
kind: flow
name: flow-name
entryPoint: start
flow:
start:
transform:
path: 'dist/get-payload-transformer.js'
nextNode: initXmlEncoder
initXmlEncoder:
xmlEncoder:
headless: false
nextNode: checkPayload
checkPayload:
transform:
path: 'dist/check-payload-transformer.js'
terminal: true
xml decoder
xml decoder flow description enables you to define the xml decoder as a flow node.
xml decoder, decodes xml string to javascript literal object.
version: 1
kind: flow
name: flow-name
entryPoint: start
flow:
start:
transform:
path: 'dist/get-payload-transformer.js'
nextNode: initXmlDecoder
initXmlDecoder:
xmlDecoder:
explicitCharkey: false
nextNode: checkPayload
checkPayload:
transform:
path: 'dist/check-payload-transformer.js'
terminal: true
API
xmlEncoder
Type: flow description
Options:
attrkey (string), optional, default = '$'
Prefix that is used to access the attributes.
charkey (string), optional, default = '_'
Prefix that is used to access the character content.
rootName (string), optional
Root element name to be used in case explicitRoot is false or to override the root element name. (default root or the root key name)
doctype (any), optional, default = null
Optional DTD. Eg. {'ext': 'hello.dtd'}.
headless (boolean), optional, default = false
Omit the XML header.
allowSurrogateChars (boolean), optional, default = false
Allows using characters from the Unicode surrogate blocks.
cdata (boolean), optional, default = false
Wrap text nodes in instead of escaping when necessary. Does not add if it is not required.
xmllDecoder
Type: flow description
Options:
key (string), optional
attrkey (string), optional, default = '$'
Prefix that is used to access the attributes.
charkey (string), optional, default = '_'
Prefix that is used to access the character content.
explicitCharkey (boolean), optional, default = false
trim (boolean), optional, default = false
Trim the whitespace at the beginning and end of text nodes.
normalizeTags (boolean), optional, default = false
Normalize all tag names to lowercase.
normalize (boolean), optional, default = false
Trim whitespaces inside text nodes.
explicitRoot (boolean), optional, default = true
Set this if you want to get the root node in the resulting object.
explicitArray (boolean), optional, default = true
Always put child nodes in an array if true; otherwise an array is created only if there is more than one.
ignoreAttrs (boolean), optional, default = false
Ignore all XML attributes and only create text nodes.
mergeAttrs (boolean), optional, default = false
Merge attributes and child elements as properties of the parent,
instead of keying attributes off a child attribute object.
This option is ignored if ignoreAttrs is true.xmlns (boolean), optional, default = false
Give each element a field usually called '$ns' (the first character is the same as attrkey)
that contains its local name and namespace URI.explicitChildren (boolean), optional, default = false
Put child elements to separate property. Doesn't work with mergeAttrs = true.
If element has no children then "children" won't be created.childkey (string), optional, default = '$$'
Prefix that is used to access child elements if explicitChildren is set to true.
preserveChildrenOrder (boolean), optional, default = false
Modifies the behavior of explicitChildren so that the value of the "children" property becomes an ordered array.
When this is true, every node will also get a #name field whose value will correspond to the XML nodeName,
so that you may iterate the "children" array and still be able to determine node names.
The named (and potentially unordered) properties are also retained in this configuration at the same level as the ordered "children" array.charsAsChildren (boolean), optional, default = false
Determines whether chars should be considered children if explicitChildren is on.
includeWhiteChars (boolean), optional, default = false
Determines whether whitespace-only text nodes should be included.
async (boolean), optional, default = false
Should the callbacks be async? This might be an incompatible change if your code depends on sync execution of callbacks.
Future versions of xml2js might change this default, so the recommendation is to not depend on sync execution anyway.strict (boolean), optional, default = true
Set sax-js to strict or non-strict parsing mode.
Defaults to true which is highly recommended,
since parsing HTML which is not well-formed XML might yield just about anything.chunkSize (number), optional
你可能也喜欢
- @01ht/ht-account-settings 中文文档教程
- @0x-lerna-fork/prompt 中文文档教程
- @0x4447/cucumber 中文文档教程
- @21epub/rxjs-event-bus 中文文档教程
- @2o3t/koa2-proxy-middleware 中文文档教程
- @2toad/fluent-state 中文文档教程
- @3kles/kles-odin-mi 中文文档教程
- @4geit/rct-conway-component 中文文档教程
- @555platform/protektor.ts 中文文档教程
- @5to3/influx-firehose-forwarder 中文文档教程