Extracts the schema.org version number (as string) from the given schema.org version URL.
This function accepts URLs with following formats (any protocol variant is allowed - http/https):
"https://schema.org/docs/releases.html#v10.0"
-> "10.0"
"https://schema.org/version/3.4/"
-> "3.4"
a URL specifying a schema.org version
The version number as a string
Identifies the used DS-Specification version used by the given Domain Specification.
The input Domain Specification
The detected DS-Specification version
Returns the used DS-Specification version of this DS-Utilities instance, which is "7.0"
.
DS-Utilities instances are always bound to a specific DS-Specification version.
Returns a human-readable label for the given DS-DataType.
DS-DataTypes are listed in the DS-V7 Specification in the XSD
column.
a compacted IRI representing a DataType of DS-V7 (from XSD
or RDF
, e.g. "xsd:string"
or "rdf:langString"
)
a human-readable label for the given DataType
Returns the author name of the given DS.
schema:author
is optional in DS-V7.
the input Domain Specification
The author name of the given DS, if any
Returns the description of the given DS for a language (there could be descriptions in different languages).
schema:description
is optional in DS-V7.
the input Domain Specification
the wished language for the description
The description of the given DS, if any
Returns the used external vocabularies of the given DS.
ds:usedVocabulary
is optional in DS-V7.
the input Domain Specification
Array with the used external vocabularies (empty if none)
Returns the name of the given DS for a language (there could be names in different languages).
schema:name
is optional in DS-V7.
the input Domain Specification
the wished language for the name
The name of the given DS, if any
Returns the used schema.org version of the given DS.
schema:schemaVersion
is mandatory in DS-V7.
the input Domain Specification
The schema.org version identifier as string, e.g. "11.0"
Returns the target classes of the given DS.
sh:targetClass
is optional in DS-V7.
the input Domain Specification
Array with the target classes (empty if none)
Returns the version of the given DS (the version of the DS instance itself).
schema:version
is optional in DS-V7.
the input Domain Specification
The ds version as string, e.g. "1.04"
Returns the "pretty" version of a compacted IRI (single IRI or array of IRIs).
If an IRI belongs to schema.org, then the IRI is returned without the schema:
vocabulary indicator.
the input IRI or array of IRIs
The pretty-string for the given input
Creates a new fragment-id according to the DS-V7 specification.
It is possible to pass a Domain Specification as parameter to ensured that the generated fragment-id has not been used in the given DS yet.
the input Domain Specification
A new the fragment-id
Returns the corresponding DS-V7 datatype (XSD/RDF) for a given schema.org datatype, according to the DsV7-DataType-Mapping.
ATTENTION: for schema:Text
the value xsd:string
is always returned (no rdf:langString
or rdf:HTML
)
a compacted IRI representing a DataType of schema.org (e.g. schema:Text
)
the corresponding DS-V7 Datatype (from XSD or RDF)
Returns the @id
of the given DS (for DS-V7 this @id is found in the root node).
An @id
is mandatory in DS-V7.
the input Domain Specification
The @id
of the given Domain Specification
Returns a reference to the root node of the given Domain Specification.
The input Domain Specification
The root node of the given Domain Specification
Returns the standard @context
for DS-V7.
The standard @context for DS-V7
Returns the corresponding schema.org datatype (XSD/RDF) for a given DS-V7 datatype, according to the DsV7-DataType-Mapping.
a compacted IRI representing a DataType of DS-V7 (from XSD or RDF, e.g. xsd:string
or rdf:langString
)
The corresponding schema.org Datatype, e.g. schema:URL
Returns the grammar-type of the given DS-Node within the given Populated Domain Specification.
It is possible to pass an SDO-Adapter to tell a standard enumeration apart from a standard class. If no SDO-Adapter is given, a standard class is assumed.
If a reference node is passed and the parameter followReference
is set to true
, then the grammar type of the referenced node is returned (e.g. internal reference that points to a Restricted Class -> RestrictedClass
) instead of the type of the reference node itself.
The possible DS-Grammar Node types are listed in the documentation of PathTokenObjectV7.
the input DS Node
the input DS (populated)
if true, the type of the referenced node is returned, instead of the type of the reference
A SDO-Adapter instance (already initialized with the wished vocabularies)
the type of the given node
Reorders the attributes of all nodes of the given Domain Specification according to their order in the Key-Value tables in the DsV7-Specification.
the input Domain Specification
Reorders the attributes of the given DS-Node according to their order in the Key-Value table in the DsV7-Specification.
The corresponding node type is detected automatically. Works only for certain ds grammar node types.
the input node from a Domain Specification
Appends a new token to a given DS-Path.
A DS-Path can be initialized with the function dsPathInit().
The inputForPath
-parameter and the resulting addition to the DS-Path depend on the token type (parameter additionType
) to be added:
additionType
= Property
-> inputForPath
must be the IRI of the Property, e.g. schema:url
additionType
= DataType
-> inputForPath
must be the IRI of the DataType, e.g. xsd:string
additionType
= Class
or Enumeration
-> inputForPath
must be the IRIs of classes/enumeration as array, e.g. [ "schema:Room", "schema:Product" ]
or [ "schema:DayOfWeek" ]
additionType
= RootReference
-> inputForPath
is not neededadditionType
= InternalReference
-> inputForPath
must be the @id
of the internal node, e.g. https://semantify.it/ds/_1hRVOT8Q#sXZwe
additionType
= ExternalReference
-> inputForPath
must be the @id
of the external node, e.g. https://semantify.it/ds/_1hRVOT8Q
additionType
= InternalExternalReference
-> inputForPath
must be the @id
of the internal node from an external node, e.g. https://semantify.it/ds/_1hRVOT8Q#sXZwe
the given DS-Path to augment
the kind of addition to be added
input that depends on the given additionType, which is used for the dsPath addition
the resulting DS-Path
Returns the corresponding node within the given Domain Specification based on the given DS-Path. (As reference, not as deep copy)
The parameter resolveReference
(default = false
) allows to set the behaviour with reference nodes: If true
, and the last token of the path is a reference node, then the referenced objected will be returned. Else the reference object will be returned.
The input Domain Specification
The input DS-Path
If true
, and the last token of the path is a reference node, then the referenced objected will be returned. Else the referencing object will be returned.
The node at the given DS-Path (by reference)
Returns the DS-Path-type of the given DS-Node within the given Domain Specification. The syntax and @id
of the given node are analyzed to determine its DS-Path-type.
The different DS-Path-types (a.k.a. DS-Path-token-type) are listed in the documentation of PathTokenObjectV7.
the input DS-Node
the input Domain Specification
the DS-Path-type of the given node
Initializes a DS-Path, based on the given input parameter.
Keep in mind that paths can only start with a @graph-node (a DS-Node that resides directly in the @graph array of the Domain Specification), the only exception is the @context path. Details about the different reference types can be found in the DS-V7 Documentation.
The parameter nodeType
(default = "RootNode"
) must be one of the following:
"RootNode"
: The DS-Path starts at the root node of the Domain Specification, this is the standard."InternalReferenceDefinition"
: The DS-Path starts with an internal reference definition."ExternalReferenceDefinition"
: The DS-Path starts with an external reference definition."InternalExternalReferenceDefinition"
: The DS-Path starts with an internal reference definition of an external reference."Context"
: The DS-Path points to the @context
of the Domain Specification.The parameter nodeId
must be used if the DS-Path starts with a reference definition, and the value for this parameter is the @id
of that reference definition, e.g. "https://semantify.it/ds/_1hRVOT8Q"
.
The newly created DS-Path can be augmented with the function dsPathAddition().
the node type of the initial token, defaults to "RootNode"
the id of the node which starts the DS-path. Can be left blank in case of "RootNode" or "Context"
the generated DS-Path
Returns an array of objects, representing the tokens of a given DS-Path.
There is a dedicated documentation for such a DS-Path-Token-Object.
The input Domain Specification
The input DS-Path
an Array of path-tokens based on the given input
Returns true
if the given classes are a valid match for the given targetClasses following the DS-V7 semantics.
This matching is important for the Class-SubClass relationship (e.g. subDS, or range subclass)
This function needs the SDO-Adapter library to work. The given sdoAdapter
must be already initialized with the wished vocabularies.
The target classes (DS)
The classes to be checked (Data)
A SDO-Adapter instance
true
if the given classes to check are valid for the given target classes
Verifies if the given Domain Specification complies to the DS-V7 specification.
It is possible to pass a config object to this verification, where the expected grammar of the DS can be configured. This function returns a meta verification report.
the input Domain Specification
config object with options for the meta verification
verification report
DsUtilitiesV7
is a Class that offers an API for DS-Specification 7.0Instances of this class can be created with following static functions of this library:
Below you can find the API functions provided by this class (categorized by functionality).