xml

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xml reads and writes DMN documents in their standard XML serialisation, projecting them onto the version-neutral types in pkg/dmn/model.

The reader is namespace-tolerant by design. DMN 1.3, 1.4 and 1.5 differ only in their MODEL namespace URI for everything Verdict evaluates, and real exporters emit a mix of them, so element matching is by local name. The writer always emits the DMN 1.5 namespace.

Index

Constants

View Source
const (
	NS13 = "https://www.omg.org/spec/DMN/20191111/MODEL/"
	NS14 = "https://www.omg.org/spec/DMN/20211108/MODEL/"
	NS15 = "https://www.omg.org/spec/DMN/20230324/MODEL/"

	// The diagram-interchange namespaces. DMNDI is versioned alongside MODEL;
	// DC and DI are not, and have been stable since 2018.
	NSDMNDI13 = "https://www.omg.org/spec/DMN/20191111/DMNDI/"
	NSDMNDI14 = "https://www.omg.org/spec/DMN/20211108/DMNDI/"
	NSDMNDI15 = "https://www.omg.org/spec/DMN/20230324/DMNDI/"
	NSDC      = "http://www.omg.org/spec/DMN/20180521/DC/"
	NSDI      = "http://www.omg.org/spec/DMN/20180521/DI/"

	// NSVerdict is where the agentDecision extension lives.
	NSVerdict = "https://github.com/frankbardon/verdict/schema/1.0"

	// FEELLanguage is the URI DMN assigns to FEEL. An expressionLanguage
	// attribute naming anything else is reported as a diagnostic.
	FEELLanguage = "https://www.omg.org/spec/DMN/20230324/FEEL/"
)

Namespace URIs, by DMN version. The reader accepts any of them; the writer emits NS15.

Variables

This section is empty.

Functions

func Marshal

func Marshal(defs *model.Definitions) ([]byte, error)

Marshal renders a model as DMN XML using the default options.

func MarshalWith

func MarshalWith(defs *model.Definitions, opts Options) ([]byte, error)

MarshalWith renders a model as DMN XML.

func Parse

func Parse(raw []byte) (*model.Definitions, []diag.Diagnostic, error)

Parse is Read over an in-memory document.

func ParseISODuration

func ParseISODuration(s string) (time.Duration, error)

ParseISODuration parses an ISO-8601 duration policy attribute. It is a thin alias for model.ParseDuration, kept here because the XML attribute is where callers meet the format.

func Read

Read parses a DMN document and projects it onto the version-neutral model.

Parsing is deliberately forgiving about content it does not understand: an unimplemented boxed expression or a Java-bound BKM becomes a stub plus a diagnostic rather than a hard failure, so one unsupported corner of a large model does not make the other ninety-nine decisions unreachable. Structural problems that make evaluation impossible — malformed XML, a cyclic DRG — are returned as errors.

func Write

func Write(w io.Writer, defs *model.Definitions) error

Write renders a model as DMN XML to w using the default options.

func WriteWith

func WriteWith(w io.Writer, defs *model.Definitions, opts Options) error

WriteWith renders a model as DMN XML to w.

Two things are worth knowing about the output. Verdict's own metadata — the model version and its conformance level — is written as attributes in the Verdict namespace, because DMN's `tDefinitions` declares no such attributes and only `##other`-namespaced ones are admitted by its `anyAttribute`. And `agentDecision` is written inside `<extensionElements>` rather than in the decision-logic slot, because that slot accepts only the DMN `expression` substitution group: a foreign element there makes the whole document fail schema validation, which is the opposite of degrading gracefully.

Types

type Options

type Options struct {
	// Namespace is the DMN MODEL namespace to emit: NS13 (the default), NS14 or
	// NS15.
	//
	// The default is 1.3, not the newest version Verdict can read, and that is a
	// deliberate interoperability choice rather than conservatism. Camunda
	// Modeler and dmn-js — between them, most of the DMN authoring in the world —
	// read 1.3 and reject a 1.5 namespace outright. A model Verdict writes is
	// worth little if the tool the modeller uses will not open it.
	Namespace string

	// Diagram emits auto-laid-out DMNDI so the document opens as a diagram
	// rather than as an empty canvas. On by default; dmn-js has nothing to draw
	// without it.
	Diagram bool
}

Options configure the writer.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the writer defaults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL