parser

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 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 parser parses XML files into generic model.Record values using a caller-supplied, config-driven field mapping. There is no hardcoded XML schema anywhere in xpro-oss — point it at any XML shape by editing the `mapping` section of config.yaml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(sourceName string, raw []byte, mapping []Mapping) (model.Record, error)

Parse applies the compiled mapping to raw XML content, producing a Record. A missing/absent XPath match yields an empty string for that column — the caller decides whether that's an error (e.g. via a NOT NULL DB constraint).

Types

type Mapping

type Mapping struct {
	Column string
	Const  *string // non-nil: use this literal value (even ""), ignore path
	// contains filtered or unexported fields
}

Mapping is a precompiled config.MappingField — compiled once at startup so repeated Parse calls don't recompile XPath expressions per file. The compiled path is unexported: Compile is the only correct constructor, and this keeps the third-party xmlpath.Path type out of this package's public API (so swapping the underlying XPath library later isn't a breaking change).

func Compile

func Compile(fields []config.MappingField) ([]Mapping, error)

Compile precompiles the configured field mappings.

Jump to

Keyboard shortcuts

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