Skip to main content

Documents

@loaders.gl/documents loads XML, HTML, JSON, YAML, TOML, BSON, and a simple Markdown subset. All document parsers are maintained in this repository. XML uses the native SAX implementation; no third-party XML or JSON parser is installed by this package.

npm install @loaders.gl/core @loaders.gl/documents

The root exports metadata loaders, format descriptors, and shared types. It does not eagerly load parsers, XML dependencies, BSON codecs, or writers. Async core APIs preload implementations:

import {load} from '@loaders.gl/core';
import {MarkdownLoader} from '@loaders.gl/documents';

const document = await load('README.md', MarkdownLoader);
LogoFormatMetadata loaderParser importOutput
—XMLXMLLoader@loaders.gl/documents/xmlJavaScript object
—HTMLHTMLLoader@loaders.gl/documents/htmlXML-style object
JSONJSONLoader@loaders.gl/documents/jsonAny JSON value, without table extraction
YAMLYAMLLoader@loaders.gl/documents/yamlObjects, arrays, scalars
TOMLTOMLLoader@loaders.gl/documents/tomlJavaScript object
BSONBSONLoader@loaders.gl/documents/bsonJavaScript object
—MarkdownMarkdownLoader@loaders.gl/documents/markdownMarkdownDocument syntax tree

Each parser subpath exports the corresponding *LoaderWithParser. Use it for sync parsing:

import {parseSync} from '@loaders.gl/core';
import {MarkdownLoaderWithParser} from '@loaders.gl/documents/markdown';

const document = parseSync('# Hello', MarkdownLoaderWithParser);

BSON and Parquet​

@loaders.gl/documents/bson-codec exports encodeBSONSync, parseBSONSync, BSONObjectId, and createBSONValue. Import BSONWriter from @loaders.gl/documents/bson. The codec preserves the existing BSON wire behavior and Parquet BSON logical-type read/write support. It does not install the MongoDB bson package. See the BSON reference.

XML utilities​

Use /xml-parser for parseXMLSync and validateXML, /sax-parser for SAXParser, and /xml-utils for convertXMLFieldToArrayInPlace, convertXMLValueToArray, and the existing experimental uncapitalization helpers. Parser and utility entry points are direct subpaths, without format groups.

Migration and credits​

This package replaces @loaders.gl/xml, @loaders.gl/config, and the tables BSON exports. See the upgrade guide for import replacements and the source and license inventory.

Native XML policies​

XML is strict by default, with one root element, bounded nesting (default 256), safe own-property construction, predefined/numeric entity decoding, and no DTD or external-entity resolution. Options control attribute prefixes/grouping, namespace removal, text keys, scalar coercion, whitespace, and singleton arrays. See XMLLoader. HTMLLoader uses the same implementation in a tolerant mode with built-in HTML entities; it remains an XML-style object reader, not an HTML5 DOM parser.

Package exports​

All exported subpaths (18)

These are the package's public exports, including format entry points, parsers, writers, sources, and worker assets.

FormatImport subpath
@loaders.gl/documents/bson
@loaders.gl/documents/bson-codec
@loaders.gl/documents/bson/bundled
@loaders.gl/documents/html
@loaders.gl/documents/html/bundled
@loaders.gl/documents/json
@loaders.gl/documents/json/bundled
@loaders.gl/documents/markdown
@loaders.gl/documents/markdown/bundled
@loaders.gl/documents/sax-parser
@loaders.gl/documents/toml
@loaders.gl/documents/toml/bundled
@loaders.gl/documents/xml
@loaders.gl/documents/xml-parser
@loaders.gl/documents/xml-utils
@loaders.gl/documents/xml/bundled
@loaders.gl/documents/yaml
@loaders.gl/documents/yaml/bundled