stax-xml
stax-xml
stax-xml
Section titled “stax-xml”Declarative XML Converter Module
Remarks
Section titled “Remarks”This module provides a zod-style declarative API for parsing XML documents. It allows you to define XML schemas using a fluent API and parse XML with XPath support.
Example
Section titled “Example”Basic usage:
import { x } from 'stax-xml/converter';
const schema = x.object({ title: x.string().xpath('/book/title'), author: x.string().xpath('/book/author'), price: x.number().xpath('/book/price')});
const xml = '<book><title>TypeScript</title><author>John</author><price>29.99</price></book>';const result = await schema.parse(xml);// { title: 'TypeScript', author: 'John', price: 29.99 }Classes
Section titled “Classes”XmlArraySchema
Section titled “XmlArraySchema”Defined in: XmlArraySchema.ts:15
Schema for parsing XML array values
Extends
Section titled “Extends”XmlSchemaBase<T["_output"][],T["_input"][]>
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlArraySchema<
T>(element,xpath?):XmlArraySchema<T>
Defined in: XmlArraySchema.ts:18
Parameters
Section titled “Parameters”element
Section titled “element”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”Overrides
Section titled “Overrides”XmlSchemaBase<T['_output'][], T['_input'][]>.constructor
Properties
Section titled “Properties”schemaType
Section titled “schemaType”
readonlyschemaType:"ARRAY"=SchemaType.ARRAY
Defined in: XmlArraySchema.ts:16
Internal
Schema type identifier
Overrides
Section titled “Overrides”XmlSchemaBase.schemaType
element
Section titled “element”
readonlyelement:T
Defined in: XmlArraySchema.ts:19
xpath?
Section titled “xpath?”
readonlyoptionalxpath:string
Defined in: XmlArraySchema.ts:20
_output
Section titled “_output”
readonly_output:T["_output"][]
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”XmlSchemaBase._output
_input
Section titled “_input”
readonly_input:T["_input"][]
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”XmlSchemaBase._input
writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeConfig
_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createTransform
_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createOptional
_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createArray
Methods
Section titled “Methods”_parse()
Section titled “_parse()”_parse(
input,parseOptions?):T["_output"][]
Defined in: XmlArraySchema.ts:25
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”T["_output"][]
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”XmlSchemaBase._parse
_parseAsync()
Section titled “_parseAsync()”_parseAsync(
input,parseOptions?):Promise<T["_output"][]>
Defined in: XmlArraySchema.ts:30
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”Promise<T["_output"][]>
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”XmlSchemaBase._parseAsync
_parseFromPosition()
Section titled “_parseFromPosition()”_parseFromPosition(
iterator,startEvent,startDepth,options?,stateMachine?,parentContext?):T["_output"][] |Promise<T["_output"][]>
Defined in: XmlArraySchema.ts:39
Internal
Parse array from current iterator position (for nested array parsing)
Parameters
Section titled “Parameters”iterator
Section titled “iterator”AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
startDepth
Section titled “startDepth”number
options?
Section titled “options?”stateMachine?
Section titled “stateMachine?”XmlParsingStateMachine
parentContext?
Section titled “parentContext?”unknown
Returns
Section titled “Returns”T["_output"][] | Promise<T["_output"][]>
Overrides
Section titled “Overrides”XmlSchemaBase._parseFromPosition
_parseText()
Section titled “_parseText()”_parseText(
text):T["_output"][]
Defined in: XmlArraySchema.ts:74
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”T["_output"][]
Parsed output
Overrides
Section titled “Overrides”XmlSchemaBase._parseText
_writeSync()
Section titled “_writeSync()”_writeSync(
data,options?):string
Defined in: XmlArraySchema.ts:84
Internal
Write array data to XML synchronously
Parameters
Section titled “Parameters”T["_output"][]
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”XmlSchemaBase._writeSync
_write()
Section titled “_write()”_write(
data,stream,options?):Promise<void>
Defined in: XmlArraySchema.ts:147
Internal
Write array data to WritableStream asynchronously
Parameters
Section titled “Parameters”T["_output"][]
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”XmlSchemaBase._write
parse()
Section titled “parse()”parse(
input,options?):Promise<T["_output"][]>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<T["_output"][]>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parse
parseSync()
Section titled “parseSync()”parseSync(
input,options?):T["_output"][]
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”T["_output"][]
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parseSync
safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<T["_output"][]>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<T["_output"][]>>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParse
safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<T["_output"][]>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<T["_output"][]>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParseSync
transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,T["_input"][]>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, T["_input"][]>
New schema with transform applied
Inherited from
Section titled “Inherited from”XmlSchemaBase.transform
optional()
Section titled “optional()”optional():
XmlSchemaBase<T["_output"][] |undefined,T["_input"][] |undefined>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][] | undefined, T["_input"][] | undefined>
New optional schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.optional
array()
Section titled “array()”array(
xpath?):XmlSchemaBase<T["_output"][][],T["_input"][][]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][][], T["_input"][][]>
New array schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.array
write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”T["_output"][]
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.write
writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”T["_output"][]
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeToStream
writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”T["_output"][]
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeSync
writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlSchemaBase.writer
XmlBuilder
Section titled “XmlBuilder”Defined in: XmlBuilder.ts:13
Builder API for creating XML schemas
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlBuilder():
XmlBuilder
Returns
Section titled “Returns”Methods
Section titled “Methods”string()
Section titled “string()”string(
xpath?):XmlStringSchema
Defined in: XmlBuilder.ts:19
Create a string schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
Optional XPath expression
Returns
Section titled “Returns”String schema
number()
Section titled “number()”number(
xpath?):XmlNumberSchema
Defined in: XmlBuilder.ts:28
Create a number schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
Optional XPath expression
Returns
Section titled “Returns”Number schema
object()
Section titled “object()”object<
T>(shape,options?):XmlObjectSchema<T>
Defined in: XmlBuilder.ts:38
Create an object schema
Type Parameters
Section titled “Type Parameters”T extends XmlObjectShape
Parameters
Section titled “Parameters”T
Object shape definition
options?
Section titled “options?”Optional object options
Returns
Section titled “Returns”Object schema
array()
Section titled “array()”array<
T>(element,xpath?):XmlArraySchema<T>
Defined in: XmlBuilder.ts:48
Create an array schema
Type Parameters
Section titled “Type Parameters”T extends XmlSchema<unknown, unknown>
Parameters
Section titled “Parameters”element
Section titled “element”T
Element schema
xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”Array schema
XmlNumberSchema
Section titled “XmlNumberSchema”Defined in: XmlNumberSchema.ts:15
Schema for parsing XML number values
Extends
Section titled “Extends”XmlSchema<number,number>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlNumberSchema(
options):XmlNumberSchema
Defined in: XmlNumberSchema.ts:18
Parameters
Section titled “Parameters”options
Section titled “options”XmlNumberOptions = {}
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Properties
Section titled “Properties”schemaType
Section titled “schemaType”
readonlyschemaType:"NUMBER"=SchemaType.NUMBER
Defined in: XmlNumberSchema.ts:16
Internal
Schema type identifier
Overrides
Section titled “Overrides”options
Section titled “options”options:
XmlNumberOptions={}
Defined in: XmlNumberSchema.ts:18
_output
Section titled “_output”
readonly_output:number
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”_input
Section titled “_input”
readonly_input:number
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_parse()
Section titled “_parse()”_parse(
input,parseOptions?):number
Defined in: XmlNumberSchema.ts:22
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”number
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”_parseAsync()
Section titled “_parseAsync()”_parseAsync(
input,parseOptions?):Promise<number>
Defined in: XmlNumberSchema.ts:28
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”Promise<number>
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”_parseText()
Section titled “_parseText()”_parseText(
text):number
Defined in: XmlNumberSchema.ts:34
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”number
Parsed output
Overrides
Section titled “Overrides”_parseFromPosition()
Section titled “_parseFromPosition()”_parseFromPosition(
iterator,startEvent,startDepth,options?):number|Promise<number>
Defined in: XmlNumberSchema.ts:86
Internal
Parse from current iterator position
Parameters
Section titled “Parameters”iterator
Section titled “iterator”AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
startDepth
Section titled “startDepth”number
options?
Section titled “options?”Returns
Section titled “Returns”number | Promise<number>
Overrides
Section titled “Overrides”xpath()
Section titled “xpath()”xpath(
path):XmlNumberSchema
Defined in: XmlNumberSchema.ts:157
Set XPath expression for locating the element
Parameters
Section titled “Parameters”string
XPath expression
Returns
Section titled “Returns”New schema with XPath
min(
value):XmlNumberSchema
Defined in: XmlNumberSchema.ts:170
Set minimum value
Parameters
Section titled “Parameters”number
Minimum value
Returns
Section titled “Returns”New schema with minimum
max(
value):XmlNumberSchema
Defined in: XmlNumberSchema.ts:179
Set maximum value
Parameters
Section titled “Parameters”number
Maximum value
Returns
Section titled “Returns”New schema with maximum
int():
XmlNumberSchema
Defined in: XmlNumberSchema.ts:187
Require integer value
Returns
Section titled “Returns”New schema that only accepts integers
_writeContent()
Section titled “_writeContent()”_writeContent(
data,options?):string
Defined in: XmlNumberSchema.ts:195
Internal
Write raw content only (used inside object schema)
Parameters
Section titled “Parameters”number
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
_writeSync()
Section titled “_writeSync()”_writeSync(
data,options?):string
Defined in: XmlNumberSchema.ts:203
Internal
Write number data to XML synchronously
Parameters
Section titled “Parameters”number
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”_write()
Section titled “_write()”_write(
data,stream,options?):Promise<void>
Defined in: XmlNumberSchema.ts:266
Internal
Write number data to WritableStream asynchronously
Parameters
Section titled “Parameters”number
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”parse()
Section titled “parse()”parse(
input,options?):Promise<number>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<number>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”parseSync()
Section titled “parseSync()”parseSync(
input,options?):number
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”number
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<number>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<number>>
Parse result with success flag
Inherited from
Section titled “Inherited from”safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<number>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<number>
Parse result with success flag
Inherited from
Section titled “Inherited from”transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,number>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, number>
New schema with transform applied
Inherited from
Section titled “Inherited from”optional()
Section titled “optional()”optional():
XmlSchemaBase<number|undefined,number|undefined>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<number | undefined, number | undefined>
New optional schema
Inherited from
Section titled “Inherited from”array()
Section titled “array()”array(
xpath?):XmlSchemaBase<number[],number[]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<number[], number[]>
New array schema
Inherited from
Section titled “Inherited from”write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”number
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”number
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”number
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlObjectSchema
Section titled “XmlObjectSchema”Defined in: XmlObjectSchema.ts:57
Schema for parsing XML object values
Extends
Section titled “Extends”XmlSchema<InferObjectOutput<T>,unknown>
Type Parameters
Section titled “Type Parameters”T extends XmlObjectShape
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlObjectSchema<
T>(shape,options):XmlObjectSchema<T>
Defined in: XmlObjectSchema.ts:60
Parameters
Section titled “Parameters”T
options
Section titled “options”XmlObjectOptions = {}
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Properties
Section titled “Properties”schemaType
Section titled “schemaType”
readonlyschemaType:"OBJECT"=SchemaType.OBJECT
Defined in: XmlObjectSchema.ts:58
Internal
Schema type identifier
Overrides
Section titled “Overrides”
readonlyshape:T
Defined in: XmlObjectSchema.ts:61
options
Section titled “options”options:
XmlObjectOptions={}
Defined in: XmlObjectSchema.ts:62
_output
Section titled “_output”
readonly_output:Output
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”_input
Section titled “_input”
readonly_input:unknown
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_parse()
Section titled “_parse()”_parse(
input,parseOptions?):InferObjectOutput<T>
Defined in: XmlObjectSchema.ts:67
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”_parseAsync()
Section titled “_parseAsync()”_parseAsync(
input,parseOptions?):Promise<InferObjectOutput<T>>
Defined in: XmlObjectSchema.ts:72
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”Promise<InferObjectOutput<T>>
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”_parseFromPosition()
Section titled “_parseFromPosition()”_parseFromPosition(
iterator,startEvent,startDepth,options?,stateMachine?,parentContext?):InferObjectOutput<T> |Promise<InferObjectOutput<T>>
Defined in: XmlObjectSchema.ts:81
Internal
Parse from current iterator position (for recursive/streaming parsing)
Parameters
Section titled “Parameters”iterator
Section titled “iterator”AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
startDepth
Section titled “startDepth”number
options?
Section titled “options?”stateMachine?
Section titled “stateMachine?”XmlParsingStateMachine
parentContext?
Section titled “parentContext?”SchemaActivation
Returns
Section titled “Returns”InferObjectOutput<T> | Promise<InferObjectOutput<T>>
Overrides
Section titled “Overrides”_parseText()
Section titled “_parseText()”_parseText(
text):InferObjectOutput<T>
Defined in: XmlObjectSchema.ts:141
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”Parsed output
Overrides
Section titled “Overrides”xpath()
Section titled “xpath()”xpath(
path):XmlObjectSchema<T>
Defined in: XmlObjectSchema.ts:152
Set XPath expression for locating the object
Parameters
Section titled “Parameters”string
XPath expression
Returns
Section titled “Returns”New schema with XPath
_writeContent()
Section titled “_writeContent()”_writeContent(
data,options?):string
Defined in: XmlObjectSchema.ts:164
Internal
Write raw content only (used inside parent object/array schema)
Parameters
Section titled “Parameters”options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
_writeSync()
Section titled “_writeSync()”_writeSync(
data,options?):string
Defined in: XmlObjectSchema.ts:193
Internal
Write object data to XML synchronously
Parameters
Section titled “Parameters”options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”_write()
Section titled “_write()”_write(
data,stream,options?):Promise<void>
Defined in: XmlObjectSchema.ts:307
Internal
Write object data to WritableStream asynchronously
Parameters
Section titled “Parameters”stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”parse()
Section titled “parse()”parse(
input,options?):Promise<InferObjectOutput<T>>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<InferObjectOutput<T>>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”parseSync()
Section titled “parseSync()”parseSync(
input,options?):Output
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Output
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<InferObjectOutput<T>>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<InferObjectOutput<T>>>
Parse result with success flag
Inherited from
Section titled “Inherited from”safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<InferObjectOutput<T>>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<InferObjectOutput<T>>
Parse result with success flag
Inherited from
Section titled “Inherited from”transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,unknown>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, unknown>
New schema with transform applied
Inherited from
Section titled “Inherited from”optional()
Section titled “optional()”optional():
XmlSchemaBase<InferObjectOutput<T> |undefined,unknown>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<InferObjectOutput<T> | undefined, unknown>
New optional schema
Inherited from
Section titled “Inherited from”array()
Section titled “array()”array(
xpath?):XmlSchemaBase<InferObjectOutput<T>[],unknown[]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<InferObjectOutput<T>[], unknown[]>
New array schema
Inherited from
Section titled “Inherited from”write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlOptionalSchema
Section titled “XmlOptionalSchema”Defined in: XmlOptionalSchema.ts:10
Schema for optional values
Extends
Section titled “Extends”XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlOptionalSchema<
T>(schema):XmlOptionalSchema<T>
Defined in: XmlOptionalSchema.ts:13
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”Overrides
Section titled “Overrides”XmlSchemaBase<T[‘_output’] | undefined, T[‘_input’] | undefined>.constructor
Properties
Section titled “Properties”schemaType
Section titled “schemaType”
readonlyschemaType:"OPTIONAL"=SchemaType.OPTIONAL
Defined in: XmlOptionalSchema.ts:11
Internal
Schema type identifier
Overrides
Section titled “Overrides”XmlSchemaBase.schemaType
schema
Section titled “schema”
readonlyschema:T
Defined in: XmlOptionalSchema.ts:13
_output
Section titled “_output”
readonly_output:T["_output"] |undefined
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”XmlSchemaBase._output
_input
Section titled “_input”
readonly_input:T["_input"] |undefined
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”XmlSchemaBase._input
writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeConfig
_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createTransform
_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createOptional
_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createArray
Methods
Section titled “Methods”_parse()
Section titled “_parse()”_parse(
input,options?):T["_output"] |undefined
Defined in: XmlOptionalSchema.ts:17
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”T["_output"] | undefined
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”XmlSchemaBase._parse
_parseAsync()
Section titled “_parseAsync()”_parseAsync(
input,options?):Promise<T["_output"] |undefined>
Defined in: XmlOptionalSchema.ts:30
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<T["_output"] | undefined>
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”XmlSchemaBase._parseAsync
_parseText()
Section titled “_parseText()”_parseText(
text):T["_output"] |undefined
Defined in: XmlOptionalSchema.ts:43
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”T["_output"] | undefined
Parsed output
Overrides
Section titled “Overrides”XmlSchemaBase._parseText
_writeSync()
Section titled “_writeSync()”_writeSync(
data,options?):string
Defined in: XmlOptionalSchema.ts:63
Internal
Write optional data to XML synchronously
Parameters
Section titled “Parameters”T["_output"] | undefined
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”XmlSchemaBase._writeSync
_write()
Section titled “_write()”_write(
data,stream,options?):Promise<void>
Defined in: XmlOptionalSchema.ts:74
Internal
Write optional data to WritableStream asynchronously
Parameters
Section titled “Parameters”T["_output"] | undefined
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”XmlSchemaBase._write
_parseFromPosition()?
Section titled “_parseFromPosition()?”
optional_parseFromPosition(iterator,startEvent,startDepth,options?):T["_output"] |Promise<T["_output"] |undefined> |undefined
Defined in: base.ts:95
Internal
Parse from current iterator position (for streaming/recursive parsing)
Parameters
Section titled “Parameters”iterator
Section titled “iterator”Event iterator at current position
AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
The start element event
startDepth
Section titled “startDepth”number
Depth of the start element
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”T["_output"] | Promise<T["_output"] | undefined> | undefined
Parsed output
Inherited from
Section titled “Inherited from”XmlSchemaBase._parseFromPosition
parse()
Section titled “parse()”parse(
input,options?):Promise<T["_output"] |undefined>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<T["_output"] | undefined>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parse
parseSync()
Section titled “parseSync()”parseSync(
input,options?):T["_output"] |undefined
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”T["_output"] | undefined
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parseSync
safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<T["_output"] |undefined>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<T["_output"] | undefined>>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParse
safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<T["_output"] |undefined>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<T["_output"] | undefined>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParseSync
transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,T["_input"] |undefined>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, T["_input"] | undefined>
New schema with transform applied
Inherited from
Section titled “Inherited from”XmlSchemaBase.transform
optional()
Section titled “optional()”optional():
XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
New optional schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.optional
array()
Section titled “array()”array(
xpath?):XmlSchemaBase<(T["_output"] |undefined)[], (T["_input"] |undefined)[]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<(T["_output"] | undefined)[], (T["_input"] | undefined)[]>
New array schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.array
write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”Data to write
T["_output"] | undefined
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.write
writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”Data to write
T["_output"] | undefined
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeToStream
writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”Data to write
T["_output"] | undefined
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeSync
writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlSchemaBase.writer
abstract XmlSchema
Section titled “abstract XmlSchema”Defined in: XmlSchema.ts:10
Main XML schema class (extends XmlSchemaBase with all methods)
Extends
Section titled “Extends”XmlSchemaBase<Output,Input>
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input = Output
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlSchema<
Output,Input>():XmlSchema<Output,Input>
Returns
Section titled “Returns”XmlSchema<Output, Input>
Inherited from
Section titled “Inherited from”XmlSchemaBase<Output, Input>.constructor
Properties
Section titled “Properties”_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createTransform
_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createOptional
_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createArray
_output
Section titled “_output”
readonly_output:Output
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”XmlSchemaBase._output
_input
Section titled “_input”
readonly_input:Input
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”XmlSchemaBase._input
schemaType
Section titled “schemaType”
abstractreadonlyschemaType:SchemaType
Defined in: base.ts:30
Internal
Schema type identifier
Inherited from
Section titled “Inherited from”XmlSchemaBase.schemaType
writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_parse()
Section titled “_parse()”
abstract_parse(input,options?):Output
Defined in: base.ts:45
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Output
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase._parse
_parseAsync()
Section titled “_parseAsync()”
abstract_parseAsync(input,options?):Promise<Output>
Defined in: base.ts:54
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<Output>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase._parseAsync
_writeSync()
Section titled “_writeSync()”
abstract_writeSync(data,options?):string
Defined in: base.ts:63
Internal
Write data to XML string synchronously
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase._writeSync
_write()
Section titled “_write()”
abstract_write(data,stream,options?):Promise<void>
Defined in: base.ts:72
Internal
Write data to WritableStream asynchronously
Parameters
Section titled “Parameters”Output
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”XmlSchemaBase._write
_parseText()?
Section titled “_parseText()?”
abstractoptional_parseText(text):Output
Defined in: base.ts:84
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”Output
Parsed output
Inherited from
Section titled “Inherited from”XmlSchemaBase._parseText
_parseFromPosition()?
Section titled “_parseFromPosition()?”
optional_parseFromPosition(iterator,startEvent,startDepth,options?):Output|Promise<Output>
Defined in: base.ts:95
Internal
Parse from current iterator position (for streaming/recursive parsing)
Parameters
Section titled “Parameters”iterator
Section titled “iterator”Event iterator at current position
AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
The start element event
startDepth
Section titled “startDepth”number
Depth of the start element
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Output | Promise<Output>
Parsed output
Inherited from
Section titled “Inherited from”XmlSchemaBase._parseFromPosition
parse()
Section titled “parse()”parse(
input,options?):Promise<Output>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<Output>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parse
parseSync()
Section titled “parseSync()”parseSync(
input,options?):Output
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Output
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parseSync
safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<Output>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<Output>>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParse
safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<Output>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<Output>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParseSync
transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
New schema with transform applied
Inherited from
Section titled “Inherited from”XmlSchemaBase.transform
optional()
Section titled “optional()”optional():
XmlSchemaBase<Output|undefined,Input|undefined>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<Output | undefined, Input | undefined>
New optional schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.optional
array()
Section titled “array()”array(
xpath?):XmlSchemaBase<Output[],Input[]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<Output[], Input[]>
New array schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.array
write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.write
writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeToStream
writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeSync
writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlSchemaBase.writer
XmlStringSchema
Section titled “XmlStringSchema”Defined in: XmlStringSchema.ts:26
Schema for parsing XML string values
Extends
Section titled “Extends”XmlSchema<string,string>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlStringSchema(
options):XmlStringSchema
Defined in: XmlStringSchema.ts:29
Parameters
Section titled “Parameters”options
Section titled “options”XmlStringOptions = {}
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Properties
Section titled “Properties”schemaType
Section titled “schemaType”
readonlyschemaType:"STRING"=SchemaType.STRING
Defined in: XmlStringSchema.ts:27
Internal
Schema type identifier
Overrides
Section titled “Overrides”options
Section titled “options”options:
XmlStringOptions={}
Defined in: XmlStringSchema.ts:29
_output
Section titled “_output”
readonly_output:string
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”_input
Section titled “_input”
readonly_input:string
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_parse()
Section titled “_parse()”_parse(
input,parseOptions?):string
Defined in: XmlStringSchema.ts:33
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”string
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”_parseAsync()
Section titled “_parseAsync()”_parseAsync(
input,parseOptions?):Promise<string>
Defined in: XmlStringSchema.ts:38
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
parseOptions?
Section titled “parseOptions?”Returns
Section titled “Returns”Promise<string>
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”_parseText()
Section titled “_parseText()”_parseText(
text):string
Defined in: XmlStringSchema.ts:43
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”string
Parsed output
Overrides
Section titled “Overrides”_parseFromPosition()
Section titled “_parseFromPosition()”_parseFromPosition(
iterator,startEvent,startDepth,options?):string|Promise<string>
Defined in: XmlStringSchema.ts:51
Internal
Parse from current iterator position
Parameters
Section titled “Parameters”iterator
Section titled “iterator”AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
startDepth
Section titled “startDepth”number
options?
Section titled “options?”Returns
Section titled “Returns”string | Promise<string>
Overrides
Section titled “Overrides”xpath()
Section titled “xpath()”xpath(
path):XmlStringSchema
Defined in: XmlStringSchema.ts:122
Set XPath expression for locating the element
Parameters
Section titled “Parameters”string
XPath expression
Returns
Section titled “Returns”New schema with XPath
_writeContent()
Section titled “_writeContent()”_writeContent(
data,options?):string
Defined in: XmlStringSchema.ts:134
Internal
Write raw content only (used inside object schema)
Parameters
Section titled “Parameters”string
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
_writeSync()
Section titled “_writeSync()”_writeSync(
data,options?):string
Defined in: XmlStringSchema.ts:142
Internal
Write string data to XML synchronously
Parameters
Section titled “Parameters”string
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”_write()
Section titled “_write()”_write(
data,stream,options?):Promise<void>
Defined in: XmlStringSchema.ts:210
Internal
Write string data to WritableStream asynchronously
Parameters
Section titled “Parameters”string
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”parse()
Section titled “parse()”parse(
input,options?):Promise<string>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<string>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”parseSync()
Section titled “parseSync()”parseSync(
input,options?):string
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”string
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<string>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<string>>
Parse result with success flag
Inherited from
Section titled “Inherited from”safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<string>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<string>
Parse result with success flag
Inherited from
Section titled “Inherited from”transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,string>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, string>
New schema with transform applied
Inherited from
Section titled “Inherited from”optional()
Section titled “optional()”optional():
XmlSchemaBase<string|undefined,string|undefined>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<string | undefined, string | undefined>
New optional schema
Inherited from
Section titled “Inherited from”array()
Section titled “array()”array(
xpath?):XmlSchemaBase<string[],string[]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<string[], string[]>
New array schema
Inherited from
Section titled “Inherited from”write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”string
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”string
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”string
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlTransformSchema
Section titled “XmlTransformSchema”Defined in: XmlTransformSchema.ts:11
Schema for transforming parsed values
Extends
Section titled “Extends”XmlSchemaBase<Output,Input>
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
IntermediateOutput
Section titled “IntermediateOutput”IntermediateOutput = unknown
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlTransformSchema<
Output,Input,IntermediateOutput>(schema,transformFn):XmlTransformSchema<Output,Input,IntermediateOutput>
Defined in: XmlTransformSchema.ts:19
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<IntermediateOutput, Input>
transformFn
Section titled “transformFn”(value) => Output
Returns
Section titled “Returns”XmlTransformSchema<Output, Input, IntermediateOutput>
Overrides
Section titled “Overrides”XmlSchemaBase<Output, Input>.constructor
Properties
Section titled “Properties”schemaType
Section titled “schemaType”
readonlyschemaType:"TRANSFORM"=SchemaType.TRANSFORM
Defined in: XmlTransformSchema.ts:12
Internal
Schema type identifier
Overrides
Section titled “Overrides”XmlSchemaBase.schemaType
schema
Section titled “schema”
readonlyschema:XmlSchemaBase<IntermediateOutput,Input>
Defined in: XmlTransformSchema.ts:15
Internal
transformFn()
Section titled “transformFn()”
readonlytransformFn: (value) =>Output
Defined in: XmlTransformSchema.ts:17
Internal
Parameters
Section titled “Parameters”IntermediateOutput
Returns
Section titled “Returns”Output
_output
Section titled “_output”
readonly_output:Output
Defined in: base.ts:23
Inherited from
Section titled “Inherited from”XmlSchemaBase._output
_input
Section titled “_input”
readonly_input:Input
Defined in: base.ts:24
Inherited from
Section titled “Inherited from”XmlSchemaBase._input
writeConfig?
Section titled “writeConfig?”
protectedoptionalwriteConfig:XmlElementWriteConfig
Defined in: base.ts:36
Internal
Writer configuration for this schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeConfig
_createTransform()
Section titled “_createTransform()”
static_createTransform: <Output,Input,NewOutput>(schema,fn) =>XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:250
Type Parameters
Section titled “Type Parameters”Output
Section titled “Output”Output
Input
NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”schema
Section titled “schema”XmlSchemaBase<Output, Input>
(value) => NewOutput
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createTransform
_createOptional()
Section titled “_createOptional()”
static_createOptional: <T>(schema) =>XmlSchemaBase<T["_output"] |undefined,T["_input"] |undefined>
Defined in: base.ts:251
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
Returns
Section titled “Returns”XmlSchemaBase<T["_output"] | undefined, T["_input"] | undefined>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createOptional
_createArray()
Section titled “_createArray()”
static_createArray: <T>(schema,xpath?) =>XmlSchemaBase<T["_output"][],T["_input"][]>
Defined in: base.ts:252
Type Parameters
Section titled “Type Parameters”T extends XmlSchemaBase<unknown, unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”T
xpath?
Section titled “xpath?”string
Returns
Section titled “Returns”XmlSchemaBase<T["_output"][], T["_input"][]>
Inherited from
Section titled “Inherited from”XmlSchemaBase._createArray
Methods
Section titled “Methods”_parse()
Section titled “_parse()”_parse(
input,options?):Output
Defined in: XmlTransformSchema.ts:28
Parse XML input synchronously
Parameters
Section titled “Parameters”XML string or sync iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Output
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”XmlSchemaBase._parse
_parseAsync()
Section titled “_parseAsync()”_parseAsync(
input,options?):Promise<Output>
Defined in: XmlTransformSchema.ts:33
Parse XML input asynchronously
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<Output>
Parsed output
Throws
Section titled “Throws”If parsing fails
Overrides
Section titled “Overrides”XmlSchemaBase._parseAsync
_parseFromPosition()
Section titled “_parseFromPosition()”_parseFromPosition(
iterator,startEvent,startDepth,options?):Output|Promise<Output>
Defined in: XmlTransformSchema.ts:42
Internal
Parse from current iterator position and apply transform
Parameters
Section titled “Parameters”iterator
Section titled “iterator”AsyncIterator<AnyXmlEvent, any, any> | Iterator<AnyXmlEvent, any, any>
startEvent
Section titled “startEvent”StartElementEvent
startDepth
Section titled “startDepth”number
options?
Section titled “options?”Returns
Section titled “Returns”Output | Promise<Output>
Overrides
Section titled “Overrides”XmlSchemaBase._parseFromPosition
_parseText()
Section titled “_parseText()”_parseText(
text):Output
Defined in: XmlTransformSchema.ts:63
Internal
Parse text content (used internally by parser)
Parameters
Section titled “Parameters”string
Text content
Returns
Section titled “Returns”Output
Parsed output
Overrides
Section titled “Overrides”XmlSchemaBase._parseText
_writeSync()
Section titled “_writeSync()”_writeSync(
data,options?):string
Defined in: XmlTransformSchema.ts:76
Internal
Write transformed data to XML synchronously Note: Transform is not reversible, so writing is not supported
Parameters
Section titled “Parameters”Output
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”string
Overrides
Section titled “Overrides”XmlSchemaBase._writeSync
_write()
Section titled “_write()”_write(
data,stream,options?):Promise<void>
Defined in: XmlTransformSchema.ts:85
Internal
Write transformed data to WritableStream asynchronously Note: Transform is not reversible, so writing is not supported
Parameters
Section titled “Parameters”Output
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options?
Section titled “options?”XmlWriteOptions
Returns
Section titled “Returns”Promise<void>
Overrides
Section titled “Overrides”XmlSchemaBase._write
parse()
Section titled “parse()”parse(
input,options?):Promise<Output>
Defined in: base.ts:109
Parse XML asynchronously (public API)
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<Output>
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parse
parseSync()
Section titled “parseSync()”parseSync(
input,options?):Output
Defined in: base.ts:120
Parse XML synchronously (public API)
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Output
Parsed output
Throws
Section titled “Throws”If parsing fails
Inherited from
Section titled “Inherited from”XmlSchemaBase.parseSync
safeParse()
Section titled “safeParse()”safeParse(
input,options?):Promise<ParseResult<Output>>
Defined in: base.ts:130
Parse XML asynchronously with error handling
Parameters
Section titled “Parameters”XML string, stream, or async iterator
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”Promise<ParseResult<Output>>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParse
safeParseSync()
Section titled “safeParseSync()”safeParseSync(
input,options?):ParseResult<Output>
Defined in: base.ts:151
Parse XML synchronously with error handling
Parameters
Section titled “Parameters”XML string or sync iterator
string | Iterator<AnyXmlEvent, any, any>
options?
Section titled “options?”Parse options
Returns
Section titled “Returns”ParseResult<Output>
Parse result with success flag
Inherited from
Section titled “Inherited from”XmlSchemaBase.safeParseSync
transform()
Section titled “transform()”transform<
NewOutput>(fn):XmlSchemaBase<NewOutput,Input>
Defined in: base.ts:171
Transform the parsed output
Type Parameters
Section titled “Type Parameters”NewOutput
Section titled “NewOutput”NewOutput
Parameters
Section titled “Parameters”(value) => NewOutput
Transform function
Returns
Section titled “Returns”XmlSchemaBase<NewOutput, Input>
New schema with transform applied
Inherited from
Section titled “Inherited from”XmlSchemaBase.transform
optional()
Section titled “optional()”optional():
XmlSchemaBase<Output|undefined,Input|undefined>
Defined in: base.ts:179
Make this schema optional
Returns
Section titled “Returns”XmlSchemaBase<Output | undefined, Input | undefined>
New optional schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.optional
array()
Section titled “array()”array(
xpath?):XmlSchemaBase<Output[],Input[]>
Defined in: base.ts:188
Convert this schema to an array schema
Parameters
Section titled “Parameters”xpath?
Section titled “xpath?”string
XPath expression for array elements
Returns
Section titled “Returns”XmlSchemaBase<Output[], Input[]>
New array schema
Inherited from
Section titled “Inherited from”XmlSchemaBase.array
write()
Section titled “write()”write(
data,options?):Promise<string>
Defined in: base.ts:198
Write data to XML string asynchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<string>
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.write
writeToStream()
Section titled “writeToStream()”writeToStream(
data,stream,options?):Promise<void>
Defined in: base.ts:221
Write data to WritableStream asynchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
Writable stream to write to
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeToStream
writeSync()
Section titled “writeSync()”writeSync(
data,options?):string
Defined in: base.ts:235
Write data to XML string synchronously (public API)
Parameters
Section titled “Parameters”Output
Data to write
options?
Section titled “options?”XmlWriteOptions
Write options
Returns
Section titled “Returns”string
XML string
Inherited from
Section titled “Inherited from”XmlSchemaBase.writeSync
writer()
Section titled “writer()”writer(
config):this
Defined in: base.ts:244
Configure writer settings for this schema
Parameters
Section titled “Parameters”config
Section titled “config”XmlElementWriteConfig
Writer configuration
Returns
Section titled “Returns”this
This schema with writer config
Inherited from
Section titled “Inherited from”XmlSchemaBase.writer
XmlParseError
Section titled “XmlParseError”Defined in: errors.ts:6
XML parse error with detailed issue information
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new XmlParseError(
issues):XmlParseError
Defined in: errors.ts:16
Parameters
Section titled “Parameters”issues
Section titled “issues”object[]
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”issues
Section titled “issues”issues:
object[]
Defined in: errors.ts:10
List of validation issues
path:
string[]
message
Section titled “message”message:
string
code:
string
Interfaces
Section titled “Interfaces”ParseOptions
Section titled “ParseOptions”Defined in: types.ts:9
Parse options for XML converter
Properties
Section titled “Properties”trimText?
Section titled “trimText?”
optionaltrimText:boolean
Defined in: types.ts:14
Whether to trim whitespace from text content
Default Value
Section titled “Default Value”falsedecodeEntities?
Section titled “decodeEntities?”
optionaldecodeEntities:boolean
Defined in: types.ts:20
Whether to decode XML entities
Default Value
Section titled “Default Value”truestrict?
Section titled “strict?”
optionalstrict:boolean
Defined in: types.ts:26
Strict mode for parsing
Default Value
Section titled “Default Value”falsemaxDepth?
Section titled “maxDepth?”
optionalmaxDepth:number
Defined in: types.ts:32
Maximum XML depth
Default Value
Section titled “Default Value”1000maxEvents?
Section titled “maxEvents?”
optionalmaxEvents:number
Defined in: types.ts:38
Maximum number of events to process
Default Value
Section titled “Default Value”1000000XmlStringOptions
Section titled “XmlStringOptions”Defined in: types.ts:46
Options for string schema
Properties
Section titled “Properties”xpath?
Section titled “xpath?”
optionalxpath:string
Defined in: types.ts:50
XPath expression to locate the element
optionalmin:number
Defined in: types.ts:55
Minimum string length
optionalmax:number
Defined in: types.ts:60
Maximum string length
pattern?
Section titled “pattern?”
optionalpattern:RegExp
Defined in: types.ts:65
Regular expression pattern to validate against
XmlNumberOptions
Section titled “XmlNumberOptions”Defined in: types.ts:73
Options for number schema
Properties
Section titled “Properties”xpath?
Section titled “xpath?”
optionalxpath:string
Defined in: types.ts:77
XPath expression to locate the element
optionalmin:number
Defined in: types.ts:82
Minimum value
optionalmax:number
Defined in: types.ts:87
Maximum value
optionalint:boolean
Defined in: types.ts:93
Whether the number must be an integer
Default Value
Section titled “Default Value”falseXmlObjectOptions
Section titled “XmlObjectOptions”Defined in: types.ts:101
Options for object schema
Properties
Section titled “Properties”xpath?
Section titled “xpath?”
optionalxpath:string
Defined in: types.ts:105
XPath expression to locate the element
strict?
Section titled “strict?”
optionalstrict:boolean
Defined in: types.ts:111
Strict mode - reject unknown properties
Default Value
Section titled “Default Value”falseType Aliases
Section titled “Type Aliases”XmlObjectShape
Section titled “XmlObjectShape”XmlObjectShape =
Record<string,XmlSchema<unknown,unknown>>
Defined in: XmlObjectSchema.ts:41
Shape type for object schema
InferObjectOutput
Section titled “InferObjectOutput”InferObjectOutput<
T> ={ [K in keyof T]: T[K]["_output"] }
Defined in: XmlObjectSchema.ts:48
Infer output type from object shape
Type Parameters
Section titled “Type Parameters”T extends XmlObjectShape
ParseInput
Section titled “ParseInput”ParseInput =
string|ReadableStream<Uint8Array> |AsyncIterator<AnyXmlEvent> |Iterator<AnyXmlEvent>
Defined in: base.ts:11
Parse input type - accepts string, sync iterator, async iterator, or ReadableStream
ParseResult
Section titled “ParseResult”ParseResult<
T> = {success:true;data:T; } | {success:false;error:XmlParseError; }
Defined in: errors.ts:28
Parse result type for safe parsing operations
Type Parameters
Section titled “Type Parameters”T
Infer<
T> =T["_output"]
Defined in: index.ts:62
Type Parameters
Section titled “Type Parameters”T extends XmlSchema<unknown, unknown>
Variables
Section titled “Variables”
constx:XmlBuilder
Defined in: XmlBuilder.ts:58
Singleton builder instance