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
- Variables
- func IngestStream(context *ls.Context, ingester *Ingester, baseID string, input io.Reader) (graph.Node, error)
- func IsWhitespaceFacet(name xml.Name) bool
- type CollapseWhitespaceFacet
- type ErrAmbiguousSchemaAttribute
- type ErrCannotHaveAttributes
- type ErrElementNodeNotTerminated
- type ErrInvalidWhitespaceFacet
- type Ingester
- type PreserveWhitespaceFacet
- type ReplaceWhitespaceFacet
- type WhitespaceFacet
Constants ¶
const XML = "https://lschema.org/xml/"
const XSDNamespace = "http://www.w3.org/2001/XMLSchema"
Variables ¶
var AttributeTerm = ls.NewTerm(XML, "attribute", false, false, ls.OverrideComposition, nil)
AttributeTerm marks the attribute as an XML attribute of an element
var DirectiveTerm = ls.NewTerm(XML, "directive", false, false, ls.OverrideComposition, nil)
var ErrExtraCharacters = errors.New("Extra characters before document")
var ErrInvalidXML = errors.New("Invalid XML")
var ErrMultipleRoots = errors.New("Multiple roots")
var LocalNameTerm = ls.NewTerm(XML, "lname", false, false, ls.OverrideComposition, nil)
LocalNameTerm captures the element/attribute local name in the ingested data graph
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.
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 ¶
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 ¶
func (ErrAmbiguousSchemaAttribute) Error ¶
func (e ErrAmbiguousSchemaAttribute) Error() string
type ErrCannotHaveAttributes ¶
type ErrCannotHaveAttributes struct {
Path string
}
func (ErrCannotHaveAttributes) Error ¶
func (e ErrCannotHaveAttributes) Error() string
type ErrElementNodeNotTerminated ¶
func (ErrElementNodeNotTerminated) Error ¶
func (e ErrElementNodeNotTerminated) Error() string
type ErrInvalidWhitespaceFacet ¶
type ErrInvalidWhitespaceFacet struct {
Name string
}
func (ErrInvalidWhitespaceFacet) Error ¶
func (e ErrInvalidWhitespaceFacet) Error() string
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 ¶
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"