xml

package
v1.0.0-beta9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 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.

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", false, false, ls.OverrideComposition, nil)

AttributeTerm marks the attribute as an XML attribute of an element

View Source
var DirectiveTerm = ls.NewTerm(XML, "directive", false, false, ls.OverrideComposition, nil)
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 LocalNameTerm = ls.NewTerm(XML, "lname", false, false, ls.OverrideComposition, nil)

LocalNameTerm captures the element/attribute local name in the ingested data graph

View Source
var NamespaceTerm = ls.NewTerm(XML, "ns", false, false, ls.OverrideComposition, nil)

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

View Source
var ProcessingInstructionTerm = ls.NewTerm(XML, "procInst", false, false, ls.OverrideComposition, nil)

Functions

func IngestStream

func IngestStream(context *ls.Context, ingester *Ingester, baseID string, input io.Reader) (graph.Node, error)

IngestStream ingests an XML from the input stream

func IsWhitespaceFacet

func IsWhitespaceFacet(name xml.Name) bool

IsWhitespaceFacet returns if the given xml name is the whitespace facet

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 ErrInvalidWhitespaceFacet

type ErrInvalidWhitespaceFacet struct {
	Name string
}

func (ErrInvalidWhitespaceFacet) Error

type Ingester

type Ingester struct {
	ls.Ingester

	Interner ls.Interner

	IncludeProcessingInstructions bool
	IncludeDirectives             bool
}

Ingester converts an XML object model into a graph using a schema

func (*Ingester) IngestDocument

func (ingester *Ingester) IngestDocument(context *ls.Context, baseID string, decoder *xml.Decoder) (graph.Node, error)

IngestDocument ingests an XML using the schema. The output will have all input nodes associated with schema nodes.

BaseID is the ID of the root object. All other attribute names are generated by appending the attribute path to baseID

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