bmecat12

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package bmecat12 supports reading and writing BMEcat files according to version 1.2 of the specification.

BMEcat is a standard for electronic product catalogs. See http://www.bmecat.org/ for details about the format. The specifications are available at http://www.bme.de/initiativen/bmecat/download/.

Index

Constants

View Source
const (
	ArticleStatusBargain     = "bargain"
	ArticleStatusNewArticle  = "new_article"
	ArticleStatusOldArticle  = "old_article"
	ArticleStatusNew         = "new"
	ArticleStatusUsed        = "used"
	ArticleStatusRefurbished = "refurbished"
	ArticleStatusCoreArticle = "core_article"
	ArticleStatusOthers      = "others"
)
View Source
const (
	DateTimeValidStartDate = "valid_start_date"
	DateTimeValidEndDate   = "valid_end_date"
)
View Source
const (
	ArticlePriceTypeNetList        = "net_list"
	ArticlePriceTypeGrosList       = "gros_list"
	ArticlePriceTypeNetCustomer    = "net_customer"
	ArticlePriceTypeNRP            = "nrp"
	ArticlePriceTypeNetCustomerExp = "net_customer_exp"
)
View Source
const (
	ArticleReferenceTypeSparepart     = "sparepart"
	ArticleReferenceTypeSimilar       = "similar"
	ArticleReferenceTypeFollowup      = "followup"
	ArticleReferenceTypeMandatory     = "mandatory"
	ArticleReferenceTypeSelect        = "select"
	ArticleReferenceTypeDiffOrderUnit = "diff_orderunit"
	ArticleReferenceTypeAccessories   = "accessories"
	ArticleReferenceTypeConsistsOf    = "consists_of"
	ArticleReferenceTypeOthers        = "others"
)
View Source
const (
	PriceFlagInclFreight   = "incl_freight"
	PriceFlagInclPacking   = "incl_packing"
	PriceFlagInclAssurance = "incl_assurance"
	PriceFlagInclDuty      = "incl_duty"
)
View Source
const (
	DateTimeAgreementStartDate = "agreement_start_date"
	DateTimeAgreementEndDate   = "agreement_end_date"
)
View Source
const (
	MimeTypeURL   = "url"
	MimeTypePDF   = "application/pdf"
	MimeTypeJPEG  = "image/jpeg"
	MimeTypeGIF   = "image/gif"
	MimeTypeHTML  = "text/html"
	MimeTypePlain = "text/plain"

	MimePurposeThumbnail = "thumbnail"
	MimePurposeNormal    = "normal"
	MimePurposeDetail    = "detail"
	MimePurposeDataSheet = "data_sheet"
	MimePurposeOthers    = "others"
)
View Source
const (
	DateTimeGenerationDate = "generation_date"
)

Variables

View Source
var (
	DefaultStartDate time.Time
	DefaultEndDate   time.Time
)
View Source
var (
	CatalogIncludesFreight   = PriceFlag{Type: PriceFlagInclFreight, Value: "true"}
	CatalogIncludesPacking   = PriceFlag{Type: PriceFlagInclPacking, Value: "true"}
	CatalogIncludesAssurance = PriceFlag{Type: PriceFlagInclAssurance, Value: "true"}
	CatalogIncludesDuty      = PriceFlag{Type: PriceFlagInclDuty, Value: "true"}
)

Functions

This section is empty.

Types

type Address

type Address struct {
	Type      string `xml:"type,attr"`
	Name      string `xml:"NAME,omitempty"`
	Name2     string `xml:"NAME2,omitempty"`
	Name3     string `xml:"NAME3,omitempty"`
	Contact   string `xml:"CONTACT,omitempty"`
	Street    string `xml:"STREET,omitempty"`
	Zip       string `xml:"ZIP,omitempty"`
	BoxNo     string `xml:"BOXNO,omitempty"`
	ZipBox    string `xml:"ZIPBOX,omitempty"`
	City      string `xml:"CITY,omitempty"`
	State     string `xml:"STATE,omitempty"`
	Country   string `xml:"COUNTRY,omitempty"`
	Phone     string `xml:"PHONE,omitempty"`
	Fax       string `xml:"FAX,omitempty"`
	Email     string `xml:"EMAIL,omitempty"`
	PublicKey string `xml:"PUBLIC_KEY,omitempty"`
	URL       string `xml:"URL,omitempty"`
	Remarks   string `xml:"ADDRESS_REMARKS,omitempty"`
}

type Agreement

type Agreement struct {
	Type    string      `xml:"type,attr,omitempty"`
	Default string      `xml:"default,attr,omitempty"`
	ID      string      `xml:"AGREEMENT_ID"`
	Dates   []*DateTime `xml:"DATETIME,omitempty"`
}

func (*Agreement) EndDate

func (a *Agreement) EndDate() time.Time

func (*Agreement) StartDate

func (a *Agreement) StartDate() time.Time

type Article

type Article struct {
	XMLName xml.Name `xml:"ARTICLE"`

	Mode         string                 `xml:"mode,attr,omitempty"`
	SupplierAID  string                 `xml:"SUPPLIER_AID"`
	Details      *ArticleDetails        `xml:"ARTICLE_DETAILS"`
	Features     []*ArticleFeatures     `xml:"ARTICLE_FEATURES,omitempty"`
	OrderDetails *ArticleOrderDetails   `xml:"ARTICLE_ORDER_DETAILS"`
	PriceDetails []*ArticlePriceDetails `xml:"ARTICLE_PRICE_DETAILS"`
	MimeInfo     *MimeInfo              `xml:"MIME_INFO,omitempty"`
	UDX          *UserDefinedExtensions `xml:"USER_DEFINED_EXTENSIONS,omitempty"`
	References   []*ArticleReference    `xml:"ARTICLE_REFERENCE,omitempty"`

	// CatalogGroupIDs is the list of CATALOG_STRUCTURE IDs gathered on the 1st pass of the parser.
	CatalogGroupIDs []string `xml:"-"`
}

Article represents a product according to the BMEcat 1.2 specification.

type ArticleDetails

type ArticleDetails struct {
	DescriptionShort        string                          `xml:"DESCRIPTION_SHORT"`
	DescriptionLong         string                          `xml:"DESCRIPTION_LONG,omitempty"`
	EAN                     string                          `xml:"EAN,omitempty"`
	SupplierAltAID          string                          `xml:"SUPPLIER_ALT_AID,omitempty"`
	BuyerAIDs               []*BuyerAID                     `xml:"BUYER_AID,omitempty"`
	ManufacturerAID         string                          `xml:"MANUFACTURER_AID,omitempty"`
	ManufacturerName        string                          `xml:"MANUFACTURER_NAME,omitempty"`
	ManufacturerTypeDescr   string                          `xml:"MANUFACTURER_TYPE_DESCR,omitempty"`
	ERPGroupBuyer           string                          `xml:"ERP_GROUP_BUYER,omitempty"`
	ERPGroupSupplier        string                          `xml:"ERP_GROUP_SUPPLIER,omitempty"`
	DeliveryTime            float32                         `xml:"DELIVERY_TIME,omitempty"`
	SpecialTreatmentClasses []*ArticleSpecialTreatmentClass `xml:"SPECIAL_TREATMENT_CLASS,omitempty"`
	Keywords                []string                        `xml:"KEYWORD,omitempty"`
	Remarks                 string                          `xml:"REMARKS,omitempty"`
	Segments                []string                        `xml:"SEGMENT,omitempty"`
	ArticleOrder            int                             `xml:"ARTICLE_ORDER,omitempty"`
	ArticleStatus           []*ArticleStatus                `xml:"ARTICLE_STATUS,omitempty"`
}

type ArticleFeatures

type ArticleFeatures struct {
	FeatureSystemName string     `xml:"REFERENCE_FEATURE_SYSTEM_NAME,omitempty"`
	FeatureGroupID    string     `xml:"REFERENCE_FEATURE_GROUP_ID,omitempty"`
	FeatureGroupName  string     `xml:"REFERENCE_FEATURE_GROUP_NAME,omitempty"`
	Features          []*Feature `xml:"FEATURE,omitempty"`
}

func (ArticleFeatures) IsEclass

func (af ArticleFeatures) IsEclass() bool

func (ArticleFeatures) IsUnspsc

func (af ArticleFeatures) IsUnspsc() bool

func (ArticleFeatures) Version

func (af ArticleFeatures) Version() string

type ArticleHandler

type ArticleHandler interface {
	HandleArticle(*Article) error
}

ArticleHandler, if implemented by a handler, is called whenever the Reader passed an ARTICLE element with a product.

type ArticleOrderDetails

type ArticleOrderDetails struct {
	OrderUnit        string  `xml:"ORDER_UNIT"`
	ContentUnit      string  `xml:"CONTENT_UNIT,omitempty"`
	NoCuPerOu        float64 `xml:"NO_CU_PER_OU,omitempty"`
	PriceQuantity    float64 `xml:"PRICE_QUANTITY,omitempty"`
	QuantityMin      float64 `xml:"QUANTITY_MIN,omitempty"`
	QuantityInterval float64 `xml:"QUANTITY_INTERVAL,omitempty"`
}

type ArticlePrice

type ArticlePrice struct {
	Type       string   `xml:"price_type,attr,omitempty"`
	Amount     float64  `xml:"PRICE_AMOUNT"`
	Currency   string   `xml:"PRICE_CURRENCY,omitempty"`
	Tax        float64  `xml:"TAX,omitempty"`
	Factor     float64  `xml:"PRICE_FACTOR,omitempty"`
	LowerBound float64  `xml:"LOWER_BOUND,omitempty"`
	Territory  []string `xml:"TERRITORY,omitempty"`
}

type ArticlePriceDetails

type ArticlePriceDetails struct {
	Dates            []*DateTime     `xml:"DATETIME,omitempty"`
	DailyPriceString string          `xml:"DAILY_PRICE,omitempty"`
	Prices           []*ArticlePrice `xml:"ARTICLE_PRICE"`
}

func (ArticlePriceDetails) IsDailyPrice

func (apd ArticlePriceDetails) IsDailyPrice() bool

func (*ArticlePriceDetails) ValidEndDate

func (apd *ArticlePriceDetails) ValidEndDate() time.Time

func (*ArticlePriceDetails) ValidStartDate

func (apd *ArticlePriceDetails) ValidStartDate() time.Time

type ArticleReference

type ArticleReference struct {
	Type           string  `xml:"type,attr"`
	Quantity       float64 `xml:"quantity,attr,omitempty"`
	ArtIDTo        string  `xml:"ART_ID_TO"`
	CatalogID      string  `xml:"CATALOG_ID,omitempty"`
	CatalogVersion string  `xml:"CATALOG_VERSION,omitempty"`
}

type ArticleSpecialTreatmentClass

type ArticleSpecialTreatmentClass struct {
	Type  string `xml:"type,attr"`
	Value string `xml:",chardata"`
}

type ArticleStatus

type ArticleStatus struct {
	Type  string `xml:"type,attr"`
	Value string `xml:",chardata"`
}

type ArticleToCatalogGroupMap

type ArticleToCatalogGroupMap struct {
	XMLName xml.Name `xml:"ARTICLE_TO_CATALOGGROUP_MAP"`

	ArticleID      string `xml:"ART_ID"`
	CatalogGroupID string `xml:"CATALOG_GROUP_ID"`
}

type Buyer

type Buyer struct {
	ID      *IDRef   `xml:"BUYER_ID,omitempty"`
	Name    string   `xml:"BUYER_NAME"`
	Address *Address `xml:"ADDRESS,omitempty"`
}

type BuyerAID

type BuyerAID struct {
	Type  string `xml:"type,attr"`
	Value string `xml:",chardata"`
}

type Catalog

type Catalog struct {
	XMLName xml.Name `xml:"CATALOG"`

	Language    string      `xml:"LANGUAGE"`
	ID          string      `xml:"CATALOG_ID"`
	Version     string      `xml:"CATALOG_VERSION"`
	Name        string      `xml:"CATALOG_NAME,omitempty"`
	GenDate     *DateTime   `xml:"DATETIME,omitempty"`
	Territories []string    `xml:"TERRITORY,omitempty"`
	Currency    string      `xml:"CURRENCY,omitempty"`
	MimeRoot    string      `xml:"MIME_ROOT,omitempty"`
	PriceFlags  []PriceFlag `xml:"PRICE_FLAG,omitempty"`
}

type CatalogGroup

type CatalogGroup struct {
	XMLName xml.Name `xml:"CATALOG_STRUCTURE"`

	Type        string  `xml:"type,attr,omitempty"`
	ID          string  `xml:"GROUP_ID"`
	Name        string  `xml:"GROUP_NAME"`
	Description string  `xml:"GROUP_DESCRIPTION,omitempty"`
	ParentID    *string `xml:"PARENT_ID,omitempty"`
	Order       int     `xml:"GROUP_ORDER,omitempty"`
	// MIME_INFO
	// USER_DEFINED_EXTENSIONS
	Keywords []string `xml:"KEYWORD,omitempty"`
}

func (*CatalogGroup) IsLeaf

func (cg *CatalogGroup) IsLeaf() bool

func (*CatalogGroup) IsNode

func (cg *CatalogGroup) IsNode() bool

func (*CatalogGroup) IsRoot

func (cg *CatalogGroup) IsRoot() bool

type CatalogGroupHandler

type CatalogGroupHandler interface {
	HandleCatalogGroup(*CatalogGroup) error
}

CatalogGroupHandler, if implemented by a handler, is called whenever the Reader passed a CATALOG_STRUCTURE element with a category.

type CatalogWriter

type CatalogWriter interface {
	Transaction() Transaction
	Language() string
	PreviousVersion() int
	Header() *Header
	ClassificationSystem() *ClassificationSystem
	Articles(context.Context) (<-chan *Article, <-chan error)
}

CatalogWriter specifies the contract that users of Writer have to implement to allow writing a BMEcat file.

type CharsetReaderFunc

type CharsetReaderFunc func(charset string, input io.Reader) (io.Reader, error)

CharsetReaderFunc typedef's the CharsetReader from the Decoder in encoding/xml.

type ClassificationGroup

type ClassificationGroup struct {
	XMLName xml.Name `xml:"CLASSIFICATION_GROUP"`

	Type        string                       `xml:"type,attr,omitempty"`
	Level       *int                         `xml:"level,attr,omitempty"`
	ID          string                       `xml:"CLASSIFICATION_GROUP_ID"`
	Name        string                       `xml:"CLASSIFICATION_GROUP_NAME"`
	Description string                       `xml:"CLASSIFICATION_GROUP_DESCR,omitempty"`
	Synonyms    []ClassificationGroupSynonym `xml:"CLASSIFICATION_GROUP_SYNONYMS,omitempty"`
	// CLASSIFICATION_GROUP_FEATURE_TEMPLATES
	ParentID string `xml:"CLASSIFICATION_GROUP_PARENT_ID,omitempty"`
}

func (*ClassificationGroup) IsLeaf

func (cg *ClassificationGroup) IsLeaf() bool

func (*ClassificationGroup) IsNode

func (cg *ClassificationGroup) IsNode() bool

type ClassificationGroupHandler

type ClassificationGroupHandler interface {
	HandleClassificationGroup(*ClassificationGroup) error
}

ClassificationGroupHandler, if implemented by a handler, is called whenever the Reader passed a CLASSIFICATION_GROUP element with a category.

type ClassificationGroupSynonym

type ClassificationGroupSynonym struct {
	Value string `xml:"SYNONYM,omitempty"`
}

type ClassificationSystem

type ClassificationSystem struct {
	XMLName xml.Name `xml:"CLASSIFICATION_SYSTEM"`

	Name        string                           `xml:"CLASSIFICATION_SYSTEM_NAME"`
	FullName    string                           `xml:"CLASSIFICATION_SYSTEM_FULLNAME,omitempty"`
	Version     string                           `xml:"CLASSIFICATION_SYSTEM_VERSION,omitempty"`
	Description string                           `xml:"CLASSIFICATION_SYSTEM_DESCR,omitempty"`
	Levels      int                              `xml:"CLASSIFICATION_SYSTEM_LEVELS,omitempty"`
	LevelNames  []*ClassificationSystemLevelName `xml:"CLASSIFICATION_SYSTEM_LEVEL_NAMES,omitempty"`
	// ALLOWED_VALUES
	// UNITS
	// CLASSIFICATION_SYSTEM_FEATURE_TEMPLATES
	Groups []*ClassificationGroup `xml:"CLASSIFICATION_GROUPS>CLASSIFICATION_GROUP,omitempty"`
}

func (*ClassificationSystem) IsBlank

func (cs *ClassificationSystem) IsBlank() bool

IsBlank returns true if there are no groups in the classification system.

type ClassificationSystemLevelName

type ClassificationSystemLevelName struct {
	XMLName xml.Name `xml:"CLASSIFICATION_SYSTEM_LEVEL_NAME"`

	Level int    `xml:"level,attr"`
	Value string `xml:",innerxml"`
}

type CompletionHandler

type CompletionHandler interface {
	HandleComplete()
}

CompletionHandler, if implemented by a handler, is called once when the Reader is done parsing the BMEcat document.

type DateTime

type DateTime struct {
	Type           string `xml:"type,attr"`
	DateString     string `xml:"DATE"`
	TimeString     string `xml:"TIME,omitempty"`
	TimeZoneString string `xml:"TIMEZONE,omitempty"`
}

func NewDateTime

func NewDateTime(typ string, dt time.Time) *DateTime

func (DateTime) Time

func (dt DateTime) Time() (time.Time, error)

type Feature

type Feature struct {
	Name         string             `xml:"FNAME"`
	Variants     []*FeatureVariants `xml:"VARIANTS,omitempty"`
	Values       []string           `xml:"FVALUE,omitempty"`
	Unit         string             `xml:"FUNIT,omitempty"`
	Order        int                `xml:"FORDER,omitempty"`
	Descr        string             `xml:"FDESCR,omitempty"`
	ValueDetails string             `xml:"FVALUE_DETAILS,omitempty"`
}

type FeatureVariant

type FeatureVariant struct {
	Value                 string `xml:"FVALUE"`
	SupplierAIDSupplement string `xml:"SUPPLIER_AID_SUPPLEMENT"`
}

type FeatureVariants

type FeatureVariants struct {
	Variants []*FeatureVariant `xml:"VARIANT"`
	Order    int               `xml:"VORDER,omitempty"`
}
type Header struct {
	XMLName xml.Name `xml:"HEADER"`

	GeneratorInfo string                 `xml:"GENERATOR_INFO,omitempty"`
	Catalog       *Catalog               `xml:"CATALOG"`
	Buyer         *Buyer                 `xml:"BUYER,omitempty"`
	Agreements    []*Agreement           `xml:"AGREEMENT,omitempty"`
	Supplier      *Supplier              `xml:"SUPPLIER,omitempty"`
	UDX           *UserDefinedExtensions `xml:"USER_DEFINED_EXTENSIONS,omitempty"`

	NumberOfArticles                  int `xml:"-"`
	NumberOfCatalogGroups             int `xml:"-"`
	NumberOfClassificationGroups      int `xml:"-"`
	NumberOfArticleToCatalogGroupMaps int `xml:"-"`
}

type HeaderHandler

type HeaderHandler interface {
	// HandleHeader, when implemented by a handler, is called when the
	// Reader passed the BMEcat HEADER element.
	//
	// HandleHeader may return io.EOF to stop the Reader from continueing
	// to read. Any other error will also stop the Reader, and the error
	// is passed to the caller of the Reader's Do method.
	HandleHeader(*Header) error
}

HeaderHandler specifies the interface for a handler that wants to get notified when the BMEcat HEADER data were read.

type IDRef

type IDRef struct {
	Type  string `xml:"type,attr"`
	Value string `xml:",chardata"`
}

type Mime

type Mime struct {
	XMLName xml.Name `xml:"MIME"`

	Type    string `xml:"MIME_TYPE,omitempty"`
	Source  string `xml:"MIME_SOURCE"`
	Descr   string `xml:"MIME_DESCR,omitempty"`
	Alt     string `xml:"MIME_ALT,omitempty"`
	Purpose string `xml:"MIME_PURPOSE,omitempty"`
	Order   int    `xml:"MIME_ORDER,omitempty"`
}

Mime represents the MIME element from the BMEcat specification.

type MimeInfo

type MimeInfo struct {
	XMLName xml.Name `xml:"MIME_INFO"`

	Mimes []*Mime `xml:"MIME"`
}

MimeInfo represents the MIME_INFO element from the BMEcat specification.

func (*MimeInfo) DataSheetSource

func (m *MimeInfo) DataSheetSource() string

DataSheetSource returns the URL of the data sheet. If no data sheet is found, an empty string is returned.

func (*MimeInfo) DetailSource

func (m *MimeInfo) DetailSource() string

DetailSource returns the URL of the detail image. If no such image can be found, an empty string is returned.

func (*MimeInfo) LogoSource

func (m *MimeInfo) LogoSource() string

LogoSource returns the URL of the logo. If no logo is found, an empty string is returned.

func (*MimeInfo) NormalSource

func (m *MimeInfo) NormalSource() string

NormalSource returns the URL of the normal image. If no such image can be found, an empty string is returned.

func (*MimeInfo) ThumbnailSource

func (m *MimeInfo) ThumbnailSource() string

ThumbnailSource returns the URL of the thumbnail image. If no such image can be found, an empty string is returned.

type PriceFlag

type PriceFlag struct {
	Type  string `xml:"type,attr"`
	Value string `xml:",innerxml"`
}

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads a BMEcat 1.2 file.

func NewReader

func NewReader(r io.ReadSeeker, options ...ReaderOption) *Reader

NewReader creates a new Reader. It expects an underlying io.ReadSeeker which essentially gets the XML content. You can also pass additional options like WithProgress.

func (*Reader) Do

func (r *Reader) Do(ctx context.Context, handler interface{}) error

Do reads the BMEcat file.

You must pass a context, which can be canceled to stop reading.

You must also pass a channel of articles, which Do loops over. If the articles channel is closed, Do will write the rest of the BMEcat file, and then return.

type ReaderOption

type ReaderOption func(*Reader)

ReaderOption is the signature of options to pass into a NewReader.

func WithCharsetReader

func WithCharsetReader(f CharsetReaderFunc) ReaderOption

WithCharsetReader specifies the charset reader to decode XML data.

func WithReaderProgress

func WithReaderProgress(f ReaderProgress) ReaderOption

WithReaderProgress specifies a callback that is invoked periodically to report progress as the BMEcat file is read.

type ReaderProgress

type ReaderProgress func(pass int, offset int64)

ReaderProgress is the signature for reporting progress. When set via WithReaderProgress, it returns the current pass of the parser (currently 1 or 2) and the current byte offset into the XML file.

type Supplier

type Supplier struct {
	ID       *IDRef    `xml:"SUPPLIER_ID"`
	Name     string    `xml:"SUPPLIER_NAME"`
	Address  *Address  `xml:"ADDRESS,omitempty"`
	MimeInfo *MimeInfo `xml:"MIME_INFO,omitempty"`
}

type Transaction

type Transaction byte
const (
	NewCatalog Transaction = iota
	UpdateProducts
	UpdatePrices
)

func (Transaction) String

func (t Transaction) String() string

type UserDefinedExtensionField

type UserDefinedExtensionField struct {
	Name     string `xml:"-"`
	Value    string `xml:",chardata"`
	InnerXML string `xml:",innerxml"`
	Raw      bool   `xml:"-"` // true to marshal Value as raw XML, i.e. not escape it
}

UserDefinedExtensionField represents a single UDX field.

type UserDefinedExtensionFields

type UserDefinedExtensionFields []*UserDefinedExtensionField

UserDefinedExtensionFields is a list of UDX fields.

func (*UserDefinedExtensionFields) Add

func (x *UserDefinedExtensionFields) Add(name, value string)

Add an UDX field to the list.

func (*UserDefinedExtensionFields) AddRaw

func (x *UserDefinedExtensionFields) AddRaw(name, value string)

AddRaw adds a UDX field with the raw value that is directly injected into the XML document. The caller is responsible for ensuring the raw value is valid XML.

func (UserDefinedExtensionFields) Get

Get returns the UDX field by name. The second return value indicates whether a field with that name actually exists.

func (UserDefinedExtensionFields) GetInnerXML

func (x UserDefinedExtensionFields) GetInnerXML(name string) (string, bool)

GetInnerXML returns the inner XML of the UDX field by name. The second return value indicates whether a field with that name actually exists.

type UserDefinedExtensions

type UserDefinedExtensions struct {
	XMLName xml.Name `xml:"USER_DEFINED_EXTENSIONS"`

	// Fields of the User-Defined-Extensions.
	//
	// Each field is a name/value pair. The name is the UDX field without the
	// "UDX." prefix. E.g. a UDX with the name "UDX.SYSTEM.CUSTOM_FIELD1" has
	// a field name of "SYSTEM.CUSTOM_FIELD1".
	Fields UserDefinedExtensionFields `xml:"-"`
}

UserDefinedExtensions allows to specify additional data. It can be used at various places in the specification, e.g. with products.

func (*UserDefinedExtensions) MarshalXML

func (x *UserDefinedExtensions) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML encodes the contents of the UserDefinedExtensions struct.

func (*UserDefinedExtensions) UnmarshalXML

func (x *UserDefinedExtensions) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML decodes the contents of the UserDefinedExtensions struct.

type WriteProgress

type WriteProgress func(written int)

WriteProgress is the signature of the progress callback while writing. You can tell the Writer to report progress with the WithProgress option.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer allows writing BMEcat 1.2 catalog files.

func NewWriter

func NewWriter(w io.Writer, options ...WriterOption) *Writer

NewWriter creates a new Writer. It expects an underlying io.Writer which essentially gets the XML content. You can also pass additional options like WithProgress.

func (*Writer) Do

func (w *Writer) Do(ctx context.Context, writer CatalogWriter) error

Do writes the BMEcat file.

You must pass a context, which can be canceled to stop writing.

You must also pass a channel of articles, which Do loops over. If the articles channel is closed, Do will write the rest of the BMEcat file, and then return.

type WriterOption

type WriterOption func(*Writer)

WriterOption is the signature of options to pass into a NewWriter.

func WithIndent

func WithIndent(indent string) WriterOption

WithIndent sets the indentation for writing the XML file. It is set to two spaces by default.

func WithProgress

func WithProgress(f WriteProgress) WriterOption

WithProgress reports the current number of articles as they are written.

Jump to

Keyboard shortcuts

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