qname

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package qname provides deterministic QName ordering helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare added in v0.0.25

func Compare(a, b QName) int

Compare orders QNames by namespace then local name.

func IsValidNCName

func IsValidNCName(s string) bool

IsValidNCName returns true if the string is a valid NCName.

func IsValidQName

func IsValidQName(s string) bool

IsValidQName returns true if the string is a valid QName.

func ParseQName

func ParseQName(name string) (prefix, local string, hasPrefix bool, err error)

ParseQName trims and validates a QName, returning prefix/local parts.

func SortInPlace added in v0.0.25

func SortInPlace(names []QName)

SortInPlace sorts QNames by namespace then local name.

func SplitQName

func SplitQName(name string) (prefix, local string, hasPrefix bool)

SplitQName splits a QName string into prefix/local without validation.

Types

type NamespaceURI

type NamespaceURI = string

NamespaceURI represents a namespace URI.

const NamespaceEmpty NamespaceURI = ""

NamespaceEmpty represents an empty namespace URI (no namespace).

func ResolveNamespace

func ResolveNamespace(prefix string, context map[string]string) (NamespaceURI, bool)

ResolveNamespace looks up a prefix in a namespace context map.

type QName

type QName struct {
	Namespace NamespaceURI
	Local     string
}

QName represents a qualified name with namespace and local part.

func ParseQNameValue added in v0.0.24

func ParseQNameValue(lexical string, nsContext map[string]string) (QName, error)

ParseQNameValue parses a QName lexical value with namespace resolution.

func SortAndDedupe added in v0.0.25

func SortAndDedupe(names []QName) []QName

SortAndDedupe sorts QNames and removes duplicates in place.

func SortedMapKeys added in v0.0.25

func SortedMapKeys[V any](m map[QName]V) []QName

SortedMapKeys returns map keys in deterministic QName order.

func (QName) Equal

func (q QName) Equal(other QName) bool

Equal returns true if two QNames are equal.

func (QName) HasLocal added in v0.0.24

func (q QName) HasLocal(local string) bool

HasLocal reports whether the local name matches, ignoring namespace.

func (QName) Is added in v0.0.24

func (q QName) Is(namespace, local string) bool

Is reports whether the QName matches the namespace and local name.

func (QName) IsZero

func (q QName) IsZero() bool

IsZero returns true if the QName is the zero value.

func (QName) String

func (q QName) String() string

String returns the QName in {namespace}local format, or just local if no namespace.

Jump to

Keyboard shortcuts

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