xml-explorer
v0.3.2
Published
React XML explorer with Monaco editor, XPath mapping and worker-based tree sync.
Readme
xml-explorer
React XML explorer component with:
- Monaco XML editor
- worker-based XPath indexing and cursor lookup
- EN16931 BT/BG tree synchronization
- strict vs nearest mapping mode
Usage
import { XMLExplorer } from "xml-explorer";
import type { TreeNode, XmlNamespaces } from "xml-explorer";
export function Example() {
const tree: TreeNode = loadYourTreeDefinition();
const namespaces: XmlNamespaces = loadYourNamespaces();
return (
<XMLExplorer
xml={xmlString}
syntax="xrechnung-cii"
tree={tree}
namespaces={namespaces}
/>
);
}xml-explorer does not ship a built-in BT/BG catalog or namespace map. Consumers must provide tree and namespaces.
For example Tree and Namespace, see here
The syntax prop is a user-defined key (string) used to select node.xpaths[syntax] across your tree.
Local development
npm install
npm run devThe Vite app in this repo is a demo host for the package.
Install (consumer app)
npm install xml-explorerRequired peer dependencies in the consumer app:
reactreact-dom@monaco-editor/reactmonaco-editor
Package API
XMLExplorer(named export)buildRuntimeTreebuildMappingsForSyntax- types:
XmlSyntax,XmlNamespaces,TreeNode,RuntimeTreeNode,NodeMapping,MatchLocation
Build package
npm run buildOutputs are written to dist/:
dist/index.js(ESM)dist/index.cjs(CJS)dist/index.d.ts(types)
Dry-run before publish
npm packInspect the generated .tgz to confirm package contents.
Publish to npm
- Ensure package name/version in
package.jsonare correct. - Login once:
npm login - Publish:
npm publish --access public
If the package name is already taken, use a scoped name like @your-scope/xml-explorer.
