xml

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2021 Cloud Privacy Labs, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const XML = "https://lschema.org/xml/"
View Source
const XSDNamespace = "http://www.w3.org/2001/XMLSchema"

Variables

View Source
var AttributeTerm = ls.NewTerm(XML, "attribute").SetComposition(ls.OverrideComposition).SetTags(ls.SchemaElementTag).Register()

AttributeTerm marks the attribute as an XML attribute of an element

View Source
var ErrExtraCharacters = errors.New("Extra characters before document")
View Source
var ErrInvalidXML = errors.New("Invalid XML")
View Source
var ErrMultipleRoots = errors.New("Multiple roots")
View Source
var NamespaceTerm = ls.NewTerm(XML, "ns").SetComposition(ls.OverrideComposition).SetTags(ls.SchemaElementTag).Register()

NamespaceTerm captures the element/attribute namespace in the ingested data graph. It also determines the namespace for the schema element/attribute.

View Source
var ValueAttributeTerm = ls.NewTerm(XML, "valueAttr").SetComposition(ls.OverrideComposition).SetTags(ls.SchemaElementTag).Register()

ValueAttributeTerm gives the name of the attribute containing the value of the node

Functions

func GetXMLName

func GetXMLName(node *lpg.Node) xml.Name

GetXMLName gets the XML name from the node's namespace and localname properties

func IsWhitespaceFacet

func IsWhitespaceFacet(name xml.Name) bool

IsWhitespaceFacet returns if the given xml name is the whitespace facet

func MatchName

func MatchName(name, requiredName xml.Name) bool

MatchName will test if name matches requiredName.

If required name has both namespace and local name, the name must match exactly.

If required name has only local name, the local name of name must match

Types

type CollapseWhitespaceFacet

type CollapseWhitespaceFacet struct{}

CollapseWhitespaceFacet works as follows: Subsequent to the replacements specified above under replace, contiguous sequences of #x20s are collapsed to a single #x20, and initial and/or final #x20s are deleted.

func (CollapseWhitespaceFacet) Filter

func (CollapseWhitespaceFacet) Filter(input string) string

type ErrAmbiguousSchemaAttribute

type ErrAmbiguousSchemaAttribute struct {
	Attr xml.Name
}

func (ErrAmbiguousSchemaAttribute) Error

type ErrCannotHaveAttributes

type ErrCannotHaveAttributes struct {
	Path string
}

func (ErrCannotHaveAttributes) Error

func (e ErrCannotHaveAttributes) Error() string

type ErrElementNodeNotTerminated

type ErrElementNodeNotTerminated struct {
	Name xml.Name
}

func (ErrElementNodeNotTerminated) Error

type ErrIncorrectElement

type ErrIncorrectElement struct {
	Name xml.Name
}

func (ErrIncorrectElement) Error

func (err ErrIncorrectElement) Error() string

type ErrInvalidWhitespaceFacet

type ErrInvalidWhitespaceFacet struct {
	Name string
}

func (ErrInvalidWhitespaceFacet) Error

type ParsedDocNode

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

func (ParsedDocNode) GetAttributeIndex

func (i ParsedDocNode) GetAttributeIndex() int

func (ParsedDocNode) GetAttributeName

func (i ParsedDocNode) GetAttributeName() string

func (ParsedDocNode) GetChildren

func (i ParsedDocNode) GetChildren() []ls.ParsedDocNode

func (ParsedDocNode) GetID

func (i ParsedDocNode) GetID() string

func (ParsedDocNode) GetProperties

func (i ParsedDocNode) GetProperties() map[string]interface{}

func (ParsedDocNode) GetSchemaNode

func (i ParsedDocNode) GetSchemaNode() *lpg.Node

func (ParsedDocNode) GetTypeTerm

func (i ParsedDocNode) GetTypeTerm() string

func (ParsedDocNode) GetValue

func (i ParsedDocNode) GetValue() string

func (ParsedDocNode) GetValueTypes

func (i ParsedDocNode) GetValueTypes() []string

type Parser

type Parser struct {
	OnlySchemaAttributes bool
	IngestEmptyValues    bool
	Layer                *ls.Layer
	// contains filtered or unexported fields
}

func (*Parser) DecodeAndParse

func (ing *Parser) DecodeAndParse(context *ls.Context, baseID string, decoder *xml.Decoder) (*ParsedDocNode, error)

func (*Parser) ParseDoc

func (ing *Parser) ParseDoc(context *ls.Context, baseID string, input *xmlElement) (*ParsedDocNode, error)

func (*Parser) ParseStream

func (ing *Parser) ParseStream(context *ls.Context, baseID string, input io.Reader) (*ParsedDocNode, error)

type PreserveWhitespaceFacet

type PreserveWhitespaceFacet struct{}

PreserveWhitespaceFacet does not do any string normalization

func (PreserveWhitespaceFacet) Filter

func (PreserveWhitespaceFacet) Filter(input string) string

type ReplaceWhitespaceFacet

type ReplaceWhitespaceFacet struct{}

ReplaceWhitespaceFacet replaces all occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space).

func (ReplaceWhitespaceFacet) Filter

func (ReplaceWhitespaceFacet) Filter(input string) string

type WhitespaceFacet

type WhitespaceFacet interface {
	Filter(string) string
}

WhitespaceFacet is the only pre-lexical facet in XSD spec, that is, whitespace normalization must be done before validation

func GetWhitespaceFacet

func GetWhitespaceFacet(facetName string) (WhitespaceFacet, error)

GetWhitespaceFacet returns the facet based on facetName being "preserve", "replace", or "collapse"

Jump to

Keyboard shortcuts

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