xmi

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 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 xmi parses XMI documents into an immutable element tree indexed by xmi:id. The fUML and PSSM test-suite readers in tools/referee and sysmlv1 interpret that tree for their respective models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUMLNamespace

func IsUMLNamespace(ns string) bool

IsUMLNamespace reports whether ns is a UML metamodel namespace.

func IsXMINamespace

func IsXMINamespace(ns string) bool

IsXMINamespace reports whether ns is an XMI namespace.

Types

type Document

type Document struct {
	Root *Element
	// contains filtered or unexported fields
}

Document is a parsed XMI file: its root and an index of every xmi:id.

func Parse

func Parse(r io.Reader) (*Document, error)

Parse reads an XMI document. It returns an error for malformed XML and for an xmi:id declared twice, and never panics on unexpected content.

func (*Document) ByID

func (d *Document) ByID(id string) *Element

ByID resolves an xmi:id within the document, nil when it names nothing.

type Element

type Element struct {
	Tag      string
	Space    string
	Type     string
	ID       string
	Attrs    map[string]string
	XMIAttrs map[string]string
	// Namespaces are the xmlns declarations on this element, prefix to URI;
	// the default namespace is under "".
	Namespaces map[string]string
	Text       string
	Children   []*Element
	Parent     *Element
	Line       int
}

Element is one XML element of an XMI document: its local tag, its xmi:type and xmi:id, its non-XMI and XMI attributes by local name, the namespaces it declares, and its children in document order. A parsed document is never modified after Parse returns.

func (*Element) Attr

func (e *Element) Attr(name string) string

Attr returns the attribute named by its local name, or "" when absent.

func (*Element) Descendants

func (e *Element) Descendants() []*Element

Descendants returns every descendant (not the element itself) in document order.

func (*Element) Describe

func (e *Element) Describe() string

Describe names an element for a diagnostic: its type, name and id.

func (*Element) First

func (e *Element) First(tag string) *Element

First returns the first child with the given tag, or nil.

func (*Element) Href

func (e *Element) Href() string

Href is the cross-document reference the element carries, or "".

func (*Element) Name

func (e *Element) Name() string

Name is the element's name attribute.

func (*Element) Namespace

func (e *Element) Namespace(prefix string) string

Namespace resolves a prefix to the URI declared for it on this element or the nearest ancestor, or "" when none declares it.

func (*Element) Ref

func (e *Element) Ref(name string) string

Ref returns the xmi:id a reference names, whether written as an attribute (`guard="_x"`) or as a child element (`<guard xmi:idref="_x"/>`), or "".

func (*Element) Refs

func (e *Element) Refs(name string) []string

Refs returns every xmi:id a multi-valued reference names: the attribute's space-separated ids and each child element's idref.

func (*Element) Tagged

func (e *Element) Tagged(tag string) []*Element

Tagged returns the children with the given tag, in document order.

func (*Element) Walk

func (e *Element) Walk(fn func(*Element) bool)

Walk visits the element and every descendant in document order until fn returns false.

Directories

Path Synopsis
Package sysmlv1 interprets the element tree of internal/translate/xmi as the UML model with stereotype applications that SysML v1 tools export.
Package sysmlv1 interprets the element tree of internal/translate/xmi as the UML model with stereotype applications that SysML v1 tools export.

Jump to

Keyboard shortcuts

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