sysmlv1

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 12 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 sysmlv1 interprets the element tree of internal/translate/xmi as the UML model with stereotype applications that SysML v1 tools export.

The reader is deliberately tolerant of the serialization's dialect: the UML, XMI and profile namespaces differ between the OMG normative XMI and the Eclipse UML2 serialization Papyrus writes, so elements are classified by the local part of their xmi:type and stereotype applications by the local part of their element name. A zip archive holding the model, such as a MagicDraw .mdzip project, is opened in place and its model entries read as one document.

The tree carries no UML semantics of its own; internal/translate/migrate interprets it as a SysML v1 model.

Index

Constants

View Source
const (
	// MagicDrawProfileNS is MagicDraw's own profile: tables and relation maps.
	MagicDrawProfileNS = "http://www.omg.org/spec/UML/20131001/MagicDrawProfile"
	// DependencyMatrixNS is MagicDraw's dependency matrix profile.
	DependencyMatrixNS = "http://www.magicdraw.com/schemas/Dependency_Matrix_Profile.xmi"
	// DocGenNS is the Open-MBEE MDK document generation profile.
	DocGenNS = "http://www.magicdraw.com/schemas/manual/Document_Profile.xmi"
	// DocGenCollaboratorNS is the MDK view collaborator profile.
	DocGenCollaboratorNS = "http://www.magicdraw.com/schemas/manual/Document_View_Collaborator_Profile.xmi"
)

Exact namespaces of the tool profiles the reader gives a typed form. Cameo serializes user profiles under the same host as its own, so only an exact namespace, never its host, identifies tool content.

Variables

This section is empty.

Functions

func IsDocGenProfile

func IsDocGenProfile(ns string) bool

IsDocGenProfile reports whether ns is one of the DocGen profiles the document mapping reads.

func IsSysMLNamespace

func IsSysMLNamespace(ns string) bool

IsSysMLNamespace reports whether ns is an OMG SysML v1 profile namespace, of any version, or Papyrus' copy of it.

func SameName

func SameName(a, b string) bool

SameName compares names up to the characters a tool replaces to make an XML name of a model name: case and everything but letters and digits.

Types

type Column

type Column struct {
	// ID is the column id as written.
	ID string
	// Kind classifies the id.
	Kind ColumnKind
	// Property is the QPROP property name: "name", "documentation", "owner"...
	Property string
	// Feature is the IColumn feature; its Element is nil when dangling.
	Feature ElementRef
	// Hidden is whether hideColumns lists the column.
	Hidden bool
}

Column is one column of a table.

type ColumnKind

type ColumnKind string

ColumnKind classifies a column id.

const (
	// ColumnTool is a tool column with no model content: row numbers, the
	// margin, an empty spacer.
	ColumnTool ColumnKind = "tool"
	// ColumnProperty is a QPROP:Element:<property> column: a UML property of
	// the row element, named by Property.
	ColumnProperty ColumnKind = "property"
	// ColumnFeature is an IColumn:<id> column: a feature of the row
	// classifier, resolved in Feature.
	ColumnFeature ColumnKind = "feature"
	// ColumnPropertyPair is the PROPERTY_COLUMN / VALUE_COLUMN pair of a
	// generic table's property view.
	ColumnPropertyPair ColumnKind = "propertyPair"
	// ColumnUnknown is an id in a form the reader does not know.
	ColumnUnknown ColumnKind = "unknown"
)

The column ids MagicDraw writes.

type Criterion

type Criterion struct {
	// Name is the display name the tool recorded; "" when none.
	Name string
	// Kind is the expression form.
	Kind CriterionKind
	// Stereotype names the relationship stereotype a relation criterion
	// walks; zero when it walks a metaclass instead.
	Stereotype StereotypeRef
	// Metaclass is the relationship metaclass a relation criterion walks;
	// "" when it walks a stereotype.
	Metaclass string
	// Direction is the walk direction as written: "DIRECT", "REVERSED",
	// "BOTH", or "" when the tool wrote none.
	Direction string
	// IncludeSubtypes is the criterion's includeSubtypes flag.
	IncludeSubtypes bool
	// Expression is the expression's xsi:type for forms other than a
	// relation, and Detail its body: the chain steps, the property, the script.
	Expression, Detail string
	// Malformed is why the criterion could not be decoded; "" when it could.
	Malformed string
}

Criterion is one dependency or relation criterion of a matrix or relation map, decoded from the structured expression the tool serialized.

type CriterionKind

type CriterionKind string

CriterionKind is the form a matrix or relation map criterion takes.

const (
	// CriterionRelation walks relationships of one stereotype or metaclass.
	CriterionRelation CriterionKind = "relation"
	// CriterionMetachain navigates a chain of UML or stereotype properties.
	CriterionMetachain CriterionKind = "metachain"
	// CriterionProperty reads one UML property.
	CriterionProperty CriterionKind = "property"
	// CriterionScript evaluates an inline script, such as OCL.
	CriterionScript CriterionKind = "script"
	// CriterionOther is any other expression form.
	CriterionOther CriterionKind = "other"
)

The criterion forms MagicDraw's structured expressions take.

type Diagram

type Diagram struct {
	// ID is the diagram's xmi:id; "" when the tool wrote none.
	ID string
	// Name is the diagram's name attribute.
	Name string
	// Kind is the tool's diagram type, such as "SysML Block Definition Diagram"
	// or "Requirement Table"; "" when the tool serialized none.
	Kind string
	// UMLKind is the UML diagram type Kind derives from, such as "Class Diagram"
	// or "Composite Structure Diagram"; "" when the tool serialized none.
	UMLKind string
	// OwnerID is the ownerOfDiagram attribute as written; "" when absent.
	OwnerID string
	// Owner is the element OwnerID resolves to; nil when it is absent or dangling.
	Owner *Element
	// Holder is the element whose xmi:Extension holds the diagram; nil at the
	// document root or inside a stereotype application.
	Holder *Element
	// Shown lists the elements the diagram shows in serialized order, each id
	// once, however many times the tool listed it.
	Shown []ElementRef
	// Extender is the tool named by the extension the diagram sits in.
	Extender string
	// Stream names the archive entry the tool serialized the diagram's symbols
	// to (a binaryObject's streamContentID); "" when none is named.
	Stream string
	// Documentation is the body of the diagram's first own comment: an
	// ownedComment annotating nothing but the diagram; "" when it has none.
	Documentation string
	// Drawn reports whether Stream was read, so that Shown lists the elements
	// the diagram's symbols display, by standing for them or for an ancestor,
	// and Free the symbols standing for none.
	Drawn bool
	// Free counts the symbols standing for no model element, such as a pasted
	// image or a text box, by the tool's symbol class; set only when Drawn.
	Free map[string]int
}

Diagram is one diagram of the model as a tool serialized it inside an xmi:Extension: what it is called, what kind of diagram it is, which element owns it and which elements it shows. Layout is not read.

func (*Diagram) Represented

func (d *Diagram) Represented() bool

Represented reports whether the tool serialized what the diagram is and shows; a diagram with neither a kind nor contents is a name and nothing more.

type DocGenDocument

type DocGenDocument struct {
	// Class is the document class; Root its view tree, of which the
	// document class is the first view.
	Class *Element
	Root  *DocGenView
	// Application is the Document application that names the class.
	Application *Stereotype
}

DocGenDocument is one MDK DocGen document: a class carrying the Document stereotype of either DocGen profile, read into its view tree.

type DocGenParagraph

type DocGenParagraph struct {
	// Application is the CollaboratorParagraph or CollaboratorImageParagraph application.
	Application *Stereotype
	// Image reports a CollaboratorImageParagraph: the comment carries an attached image file.
	Image bool
	// Comment is the comment shown; nil when the application's base is dangling.
	Comment *Element
	// Malformed is why the paragraph cannot be shown, "" when it can.
	Malformed string
	// Placed reports whether siblingId named a paragraph of the same view,
	// which this one then follows; false also when siblingId is empty.
	Placed bool
}

DocGenParagraph is one collaborator paragraph: a comment the collaborator profile places in a view (its ownerId) of a document (its viewId), after the paragraph its siblingId names.

type DocGenStep

type DocGenStep struct {
	// Node is the activity node.
	Node *Element
	// Kind is the DocGen stereotype the node or its called behavior carries,
	// "" when neither carries one.
	Kind string
	// Application is that stereotype's application.
	Application *Stereotype
	// Behavior is the behavior a CallBehaviorAction calls; nil otherwise.
	Behavior *Element
	// Targets are the node's explicit targets: its targets tag or its Expose
	// suppliers; nil when the step works on what the chain feeds it.
	Targets []ElementRef
	// Branches are the parallel chains a fork opened, each ending at the
	// node that rejoins them; Kind then names the join: "Union" for a merge,
	// "Intersection" for a join, "XOR" for a decision.
	Branches [][]*DocGenStep
	// Malformed is why the step could not be read, "" when it could.
	Malformed string
}

DocGenStep is one node of a DocGen activity chain: a collect, filter or sort step, a presentation node, a group, or a join of parallel branches.

func (*DocGenStep) Flag

func (s *DocGenStep) Flag(name string, def bool) bool

Flag reads a boolean tag of the step's application; def when absent.

func (*DocGenStep) Int

func (s *DocGenStep) Int(name string, def int) (int, error)

Int reads an integer tag of the step's application; def when absent.

type DocGenView

type DocGenView struct {
	// Class is the view class.
	Class *Element
	// Viewpoint is the viewpoint the view conforms to; nil when none.
	Viewpoint *Element
	// Method is the viewpoint's method activity, the behavior of its
	// operation named View or its method tag; nil when the viewpoint has none.
	Method *Element
	// MethodMalformed is why the viewpoint's method tag yields no activity,
	// "" when it does or the viewpoint declares no method.
	MethodMalformed string
	// Exposed are the elements the view exposes or imports, in document order.
	Exposed []ElementRef
	// Paragraphs are the collaborator paragraphs placed in this view, in the
	// order they are shown.
	Paragraphs []*DocGenParagraph
	// Children are the child views, in property order.
	Children []*DocGenView
	// Malformed lists what could not be read.
	Malformed []string
}

DocGenView is one view of a document: a class the SysML View stereotype applies to, placed by the composite properties of its parent view.

type Element

type Element struct {
	// ID is the xmi:id, or the href for a proxy of an external element.
	ID string
	// Type is the local name of the xmi:type, such as "Class" or "Property".
	// A proxy carries the type its reference declared, or "".
	Type string
	// Role is the XML element name that owns this element in its parent, such
	// as "packagedElement" or "ownedAttribute"; empty for a root.
	Role string
	// Name is the element's name attribute; a proxy takes the href fragment
	// when it reads as a name.
	Name string
	// Href is set on a proxy for an element of another document.
	Href string
	// QualifiedName is the name a tool records beside an href for the element it
	// points to (MagicDraw's referentPath); "" when the document gives none.
	QualifiedName string
	// Attrs holds the XML attributes other than xmi:id and xmi:type, keyed by
	// local name; references appear as their raw id text.
	Attrs map[string]string
	// Text is the element's character content, which stereotype tag values
	// and opaque expression bodies are written as.
	Text     string
	Parent   *Element
	Children []*Element
	// Stereotypes are the stereotype applications whose base is this element.
	Stereotypes []*Stereotype
	// contains filtered or unexported fields
}

Element is one node of the model: a UML element with an xmi:id, or a proxy for an element in another document that an href points at.

func (*Element) Applied

func (e *Element) Applied(namespace, name string) *Stereotype

Applied returns e's application of the named stereotype from one exact profile namespace, or nil; a homonym from another profile does not count.

func (*Element) DocGen

func (e *Element) DocGen() *Stereotype

DocGen returns the DocGen application on e, from either DocGen profile.

func (*Element) DocGenView

func (e *Element) DocGenView() bool

DocGenView reports whether the DocGen profile's own view stereotype applies to e, which makes a class a view as the SysML «View» does.

func (*Element) HasStereotype

func (e *Element) HasStereotype(names ...string) bool

HasStereotype reports whether any of the named stereotypes applies to e.

func (*Element) HrefOwnerName

func (e *Element) HrefOwnerName() string

HrefOwnerName reads the name a proxy's href fragment spells for its owner: SysML.xmi#SysML.AbstractRequirement.id is owned by AbstractRequirement.

func (*Element) IsProxy

func (e *Element) IsProxy() bool

IsProxy reports whether e stands for an element of another document.

func (*Element) Owned

func (e *Element) Owned(role string) []*Element

Owned returns the children of e in a role, such as its "ownedAttribute"s.

func (*Element) Path

func (e *Element) Path() []string

Path returns the names from the root to e, for diagnostics; anonymous elements contribute their type in angle brackets.

func (*Element) RefIDs

func (e *Element) RefIDs(role string) []string

RefIDs lists the raw ids a role of e refers to, attribute ids first: xmi:ids within the document, or the hrefs of elements other documents hold, kept as written even once such an href resolves to a bundled copy of its element.

func (*Element) Stereotype

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

Stereotype returns e's application of the named stereotype, or nil.

type ElementRef

type ElementRef struct {
	// ID is the xmi:id the tool wrote, or the href of an element of another
	// document, with a local href's fragment marker removed.
	ID string
	// Element is the element ID resolves to: one the read documents define, or
	// the proxy standing for one of another document; nil when it is dangling.
	Element *Element
}

ElementRef is one element a diagram shows.

type Extension

type Extension struct {
	// Extender is the tool named by the block's extender attribute.
	Extender string
	// Owner is the element the block sits in; nil at the document root.
	Owner *Element
	// Elements are the xmi:type and name of every typed element inside, the
	// diagrams excepted, which Model.Diagrams holds.
	Elements []ExtensionElement
}

Extension records one skipped xmi:Extension: who wrote it and what it held, less the ElementValue operands read into the model (see adoptValues).

type ExtensionElement

type ExtensionElement struct {
	ID, Type, Name string
}

ExtensionElement is one typed element inside a skipped extension.

type Model

type Model struct {
	// Roots are the top-level UML elements, in document order.
	Roots []*Element
	// Stereotypes are every stereotype application, in document order.
	Stereotypes []*Stereotype
	// Exporter records the xmi:Documentation exporter, when the document names one.
	Exporter string
	// Extensions are the tool-private xmi:Extension blocks that were skipped.
	Extensions []Extension
	// Diagrams are the diagrams read out of those blocks, in document order.
	Diagrams []Diagram
	// Tables are the table, matrix and relation map definitions read out of
	// the tool profile applications, in document order.
	Tables []*Table
	// Documents are the MDK DocGen documents, in document order.
	Documents []*DocGenDocument
	// StrayParagraphs are collaborator paragraphs no document's view shows.
	StrayParagraphs []*DocGenParagraph
	// contains filtered or unexported fields
}

Model is one document, or one archive's documents read as one.

func Parse

func Parse(data []byte) (*Model, error)

Parse reads an XMI document, or a zip archive (such as a MagicDraw .mdzip) holding one or more, into a Model.

func (*Model) Ambiguous

func (m *Model) Ambiguous(id string) []string

Ambiguous lists the hrefs a bare id could stand for when proxies of several documents share it as their fragment, in first-seen order; nil when the id resolves, or when no proxy carries it.

func (*Model) Ancestors

func (m *Model) Ancestors(e *Element) []*Element

Ancestors returns every classifier e specializes, transitively, nearest first and each once, in-document elements and proxies alike. e itself is among them exactly when its generalizations cycle back to it.

func (*Model) Applications

func (m *Model) Applications(namespace string) []*Stereotype

Applications lists the stereotype applications of one exact profile namespace, in document order.

func (*Model) Diagram

func (m *Model) Diagram(id string) *Diagram

Diagram finds the diagram with xmi:id id, or the one an href's fragment names; nil when no diagram has it.

func (*Model) DocGenChain

func (m *Model) DocGenChain(a *Element) ([]*DocGenStep, string)

DocGenChain reads the activity chain of a DocGen behavior or structured node: the steps reached from its initial node along single control flows, with parallel branches folded into the step that rejoins them.

func (*Model) Generals

func (m *Model) Generals(e *Element) []*Element

Generals returns the classifiers e directly specializes through its generalizations: elements of the documents read, or proxies for others.

func (*Model) Lookup

func (m *Model) Lookup(id string) *Element

Lookup resolves an xmi:id, or an href of an element another document holds, to its element; nil when the document defines neither.

func (*Model) Ref

func (m *Model) Ref(e *Element, role string) *Element

Ref returns the first element a role refers to, or nil.

func (*Model) Refs

func (m *Model) Refs(e *Element, role string) []*Element

Refs returns the elements a role of e refers to: the ids in the attribute of that name (space-separated, as XMI writes multi-valued references) and the child elements of that name carrying xmi:idref or href. Unresolvable ids are dropped (Unresolved lists them); an href yields a proxy element.

func (*Model) StereotypeRef

func (m *Model) StereotypeRef(id string) StereotypeRef

StereotypeRef resolves an id or href to the stereotype it names: through the tool's stereotype table, else through a bundled Stereotype element, whose profile namespace is the owning Profile's URI when it declares one.

func (*Model) TagRefs

func (m *Model) TagRefs(s *Stereotype, tag string) []ElementRef

TagRefs resolves a reference-valued tag of a stereotype application to the elements it names, one ElementRef per id in serialized order, an href of another document yielding its proxy and a dangling id a nil Element.

func (*Model) Unresolved

func (m *Model) Unresolved(e *Element, role string) []string

Unresolved returns the ids a role of e refers to that no read document defines, so a caller can tell a complete reference list from a dangling one.

func (*Model) UnresolvedGenerals

func (m *Model) UnresolvedGenerals(e *Element) []string

UnresolvedGenerals lists the ids of generals of e no document read defines.

type Sort

type Sort struct {
	// Column is the column id sorted by, in the form Column.ID uses.
	Column string
	// Descending is the direction.
	Descending bool
}

Sort is one sort key: a column id and a direction.

type Stereotype

type Stereotype struct {
	ID string
	// Name is the stereotype's local name, such as "Block" or "Requirement": the
	// model name of a resolved Definition, else the XML name the tool wrote.
	Name string
	// Namespace is the XML namespace the profile was serialized under.
	Namespace string
	// BaseID is the value of the base_* attribute; Base resolves it.
	BaseID string
	Base   *Element
	// Definition is the uml:Stereotype the application instantiates, when a
	// document read defines it and the application can be traced to it: through
	// the tool's stereotypesHREFS table, or by name within the profile the
	// application's XML namespace denotes. Nil otherwise.
	Definition *Element
	// Generals are every stereotype Definition specializes, transitively:
	// Model.Ancestors of the definition, so proxies stand for those defined
	// outside the documents read. Empty without a Definition.
	Generals []*Element
	// Tags holds the tagged values: attributes other than xmi:* and base_*, and
	// child elements as their text or idref, keyed by tag name. A multi-valued
	// tag lists each value.
	Tags map[string][]string
	// contains filtered or unexported fields
}

Stereotype is one stereotype application: an element outside the UML model whose base_* attribute names the element it extends.

func (*Stereotype) Bool

func (s *Stereotype) Bool(name string) bool

Bool reads a boolean tag; absent or unparsable is false.

func (*Stereotype) IDs

func (s *Stereotype) IDs(name string) []string

IDs returns the ids a reference-valued tag lists: an IDREFS attribute split on whitespace, a child element's idref or href kept whole, since an href into another archive entry may contain spaces.

func (*Stereotype) Tag

func (s *Stereotype) Tag(name string) string

Tag returns the first value of a tag, or "".

type StereotypeRef

type StereotypeRef struct {
	// ID is the id or href as written.
	ID string
	// Name is the stereotype's name; "" when the document does not tell.
	Name string
	// Namespace is the profile namespace the name belongs to; "" when unknown.
	Namespace string
	// Element is the bundled stereotype element; nil when the profile is not
	// in the read documents.
	Element *Element
}

StereotypeRef names a stereotype an id refers to: by the namespace and name its profile declared it under when the document tells, by its element when the profile is bundled, and by the raw id always.

func (StereotypeRef) Known

func (r StereotypeRef) Known() bool

Known reports whether the document told what stereotype the id names.

type Table

type Table struct {
	// Kind is the table's kind.
	Kind TableKind
	// Diagram is the diagram the definition applies to; nil when the
	// base_Diagram id names no diagram of the read documents.
	Diagram *Diagram
	// DiagramID is the base_Diagram id as written.
	DiagramID string
	// Application is the profile application that defines the table; Filter
	// is the matrix's MatrixFilter application, nil otherwise.
	Application, Filter *Stereotype
	// Scope lists the elements whose subtrees are searched for rows: a
	// table's scope, a matrix's rowScope, a relation map's contextElement.
	Scope []ElementRef
	// WholeModel is the takeWholeModelAsScope flag.
	WholeModel bool
	// RowTypes are the classifiers, stereotypes or metaclasses rows must be
	// of: a table's classifiers or rowElementType, a matrix's
	// rowElementType, a relation map's elementTypes.
	RowTypes []ElementRef
	// IncludeSubtypes is whether rows of subtypes of RowTypes are listed too;
	// MagicDraw defaults it to true.
	IncludeSubtypes bool
	// Rows are the elements listed as rows regardless of scope: a table's
	// rowElements and additionalElements.
	Rows []ElementRef
	// Columns are the table's columns in serialized order, hidden ones included.
	Columns []Column
	// Sorts are the table's sort keys in priority order.
	Sorts []Sort
	// ColumnScope and ColumnTypes are a matrix's columnScope and
	// columnElementType; IncludeColumnSubtypes its includeSubtypesOfColumnTypes.
	ColumnScope, ColumnTypes []ElementRef
	IncludeColumnSubtypes    bool
	// Direction is a matrix's direction tag: "Row to column", "Column to row"
	// or "Both".
	Direction string
	// ShowElements is a matrix's showElements tag: "All" or "With relations".
	ShowElements string
	// Criteria are a matrix's dependencyCriteria or a relation map's
	// relationCriterion, in serialized order.
	Criteria []Criterion
	// Depth is a relation map's depth; 0 when absent.
	Depth int
	// Malformed lists what in the serialization could not be read, each a
	// short phrase naming the tag and the value.
	Malformed []string
}

Table is the semantic definition of a MagicDraw table, dependency matrix or relation map: what it lists, how it filters, sorts and lays out columns, read from the tool's exact profile applications on the diagram. The presentation tags of those applications are not read.

type TableKind

type TableKind string

TableKind is what kind of tabular diagram a Table defines.

const (
	InstanceTable    TableKind = "InstanceTable"
	DiagramTable     TableKind = "DiagramTable"
	DependencyMatrix TableKind = "DependencyMatrix"
	RelationMap      TableKind = "RelationMap"
)

The MagicDraw diagram kinds that carry a semantic definition.

Jump to

Keyboard shortcuts

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