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.
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 GetXMLName(node *lpg.Node) xml.Name
- func IsWhitespaceFacet(name xml.Name) bool
- func MatchName(name, requiredName xml.Name) bool
- type CollapseWhitespaceFacet
- type ErrAmbiguousSchemaAttribute
- type ErrCannotHaveAttributes
- type ErrElementNodeNotTerminated
- type ErrIncorrectElement
- type ErrInvalidWhitespaceFacet
- type ParsedDocNode
- func (i ParsedDocNode) GetAttributeIndex() int
- func (i ParsedDocNode) GetAttributeName() string
- func (i ParsedDocNode) GetChildren() []ls.ParsedDocNode
- func (i ParsedDocNode) GetID() string
- func (i ParsedDocNode) GetProperties() map[string]interface{}
- func (i ParsedDocNode) GetSchemaNode() *lpg.Node
- func (i ParsedDocNode) GetTypeTerm() string
- func (i ParsedDocNode) GetValue() string
- func (i ParsedDocNode) GetValueTypes() []string
- type Parser
- func (ing *Parser) DecodeAndParse(context *ls.Context, baseID string, decoder *xml.Decoder) (*ParsedDocNode, error)
- func (ing *Parser) ParseDoc(context *ls.Context, baseID string, input *xmlElement) (*ParsedDocNode, error)
- func (ing *Parser) ParseStream(context *ls.Context, baseID string, input io.Reader) (*ParsedDocNode, error)
- 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").SetComposition(ls.OverrideComposition).SetTags(ls.SchemaElementTag).Register()
AttributeTerm marks the attribute as an XML attribute of an element
var ErrExtraCharacters = errors.New("Extra characters before document")
var ErrInvalidXML = errors.New("Invalid XML")
var ErrMultipleRoots = errors.New("Multiple roots")
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.
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 ¶
GetXMLName gets the XML name from the node's namespace and localname properties
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 ErrIncorrectElement ¶
func (ErrIncorrectElement) Error ¶
func (err ErrIncorrectElement) Error() string
type ErrInvalidWhitespaceFacet ¶
type ErrInvalidWhitespaceFacet struct {
Name string
}
func (ErrInvalidWhitespaceFacet) Error ¶
func (e ErrInvalidWhitespaceFacet) Error() string
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 (*Parser) ParseStream ¶
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"