Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<a> tag mapping to manage URL #fragment #1440

Merged
merged 26 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f6ead86
feat: Added <a> tag mapping to manage URL #fragment
gfoo Sep 17, 2019
9339c11
docs: updated
gfoo Sep 18, 2019
ec7d313
doc: incremental update (by hand) of standoff-data.ttl
gfoo Sep 18, 2019
380121a
feat: updated due to new standard mapping
gfoo Sep 18, 2019
e2a5c87
fix: indent
gfoo Sep 18, 2019
bd11ffc
test: HTML with internal anchor link
gfoo Sep 18, 2019
339c708
fix: md typo
gfoo Sep 18, 2019
e3513a1
fix: md typo
gfoo Sep 18, 2019
a4d2cff
fix: missing internal-link def in test data
gfoo Sep 18, 2019
6555a8e
fix: undo last modifications (error comes from elsewhere)
gfoo Sep 18, 2019
bfa2750
fix: missing internal-link def in test data (finally fix in commit #a…
gfoo Sep 19, 2019
62124f1
test: added internal-link on text value with standoff creation
gfoo Sep 19, 2019
ab3adaf
fix(standoff): Fix parsing of internal reference tag from triplestore.
Sep 23, 2019
f156202
fix(standoff): Fix insertion of # in internal reference attribute.
Sep 23, 2019
9c64d09
Merge branch 'develop' into wip/standoff-internal-anchor
Sep 24, 2019
858cea3
test: a very long text value with standoff and linked tags
gfoo Sep 24, 2019
8d0a10f
Merge branch 'develop' into wip/standoff-internal-anchor
tobiasschweizer Sep 25, 2019
b2e7f8f
fix(standoff): Get target XML ID when querying internal reference tag.
Sep 25, 2019
6cffc24
Merge branch 'develop' into wip/standoff-internal-anchor
Sep 25, 2019
789ea63
fix(standoff): Fix compile error.
Sep 25, 2019
bfe2f1d
fix(standoff): Fix so v1 SPARQL queries also work.
Sep 25, 2019
108b9f2
feat(standoff): Add update script.
Sep 25, 2019
41475fd
test (standoff): add tests for StandoffUtilV2
Sep 25, 2019
40be041
test (standoff): add tests for StandoffUtilV2 for v1 and v2
Sep 25, 2019
5051772
fix(standoff): Include targetHasOriginalXMLID in standoff system prop…
Sep 25, 2019
a35c8be
refactor(standoff): Remove redundant filtering of targetHasOriginalXM…
Sep 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 102 additions & 102 deletions docs/src/paradox/03-apis/api-v1/xml-to-standoff-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and properties defined in the ontology:
- `<strike>` → `standoff:StandoffStrikeTag`
- `<a href="URL">` → `knora-base:StandoffUriTag`
- `<a class="salsah-link" href="Knora IRI">` → `knora-base:StandoffLinkTag`
- `<a class="internal-link" href="#fragment">` → `knora-base:StandoffInternalReferenceTag`
- `<h1>` to `<h6>` → `standoff:StandoffHeader1Tag` to `standoff:StandoffHeader6Tag`
- `<ol>` → `standoff:StandoffOrderedListTag`
- `<ul>` → `standoff:StandoffUnrderedListTag`
Expand Down Expand Up @@ -98,8 +99,7 @@ relations, so the XML can be recreated from the data in RDF. However,
since HTML offers a very limited set of elements, Knora mappings support
the combination of element names and classes. In this way, the same
element can be used several times in combination with another classname
(please note that `<a>` without a class is a mere hyperlink whereas `<a
class="salsah-link">` is an internal link/standoff link).
(please note that `<a>` without a class is a mere hyperlink whereas `<a class="salsah-link">` is an internal link/standoff link).

With a mapping, a default XSL transformation may be provided to
transform the XML to HTML before sending it back to the client. This is
Expand All @@ -113,75 +113,75 @@ structure (the indentation corresponds to the nesting in XML):

- `<mapping>`: the root element

- `<defaultXSLTransformation> (optional)`: the Iri of the
default XSL transformation to be applied to the XML when
reading it back from Knora. The XSL transformation is
expected to produce HTML. If given, the Iri has to refer to
a resource of type `knora-base:XSLTransformation`.

- `<mappingElement>`: an element of the mapping (at least
one)

- `<tag>`: information about the XML element that
is mapped to a standoff class

- `<name>`: name of the XML element
- `<class>`: value of the class attribute of
the XML element, if any. If the element has
no class attribute, the keyword `noClass`
has to be used.
- `<namespace>`: the namespace the XML element
belongs to, if any. If the element does not
belong to a namespace, the keyword
`noNamespace` has to be used.
- `<separatesWords>`: a Boolean value
indicating whether this tag separates words
in the text. Once an XML document is
converted to RDF-standoff the markup is
stripped from the text, possibly leading to
continuous text that has been separated by
tags before. For structural tags like
paragraphs etc., `<separatesWords>` can be
set to `true` in which case a special
separator is inserted in the the text in the
RDF representation. In this way, words stay
separated and are represented in the
fulltext index as such.

- `<standoffClass>`: information about the
standoff class the XML element is mapped to

- `<classIri>`: Iri of the standoff class the
XML element is mapped to

- `<attributes>`: XML attributes to be
mapped to standoff properties (other
than `id` or `class`), if any

- `<attribute>`: an XML attribute
to be mapped to a standoff
property, may be repeated

- `<attributeName>`: the name
of the XML attribute
- `<namespace>`: the namespace
the attribute belongs to, if
any. If the attribute does
not belong to a namespace,
the keyword `noNamespace`
has to be used.
- `<propertyIri>`: the Iri of
the standoff property the
XML attribute is mapped to.

- `<datatype>`: the data type of the
standoff class, if any.

- `<type>`: the Iri of the data type
standoff class
- `<attributeName>`: the name of the
attribute holding the typed value in
the expected Knora standard format
- `<defaultXSLTransformation> (optional)`: the Iri of the
default XSL transformation to be applied to the XML when
reading it back from Knora. The XSL transformation is
expected to produce HTML. If given, the Iri has to refer to
a resource of type `knora-base:XSLTransformation`.

- `<mappingElement>`: an element of the mapping (at least
one)

- `<tag>`: information about the XML element that
is mapped to a standoff class

- `<name>`: name of the XML element
- `<class>`: value of the class attribute of
the XML element, if any. If the element has
no class attribute, the keyword `noClass`
has to be used.
- `<namespace>`: the namespace the XML element
belongs to, if any. If the element does not
belong to a namespace, the keyword
`noNamespace` has to be used.
- `<separatesWords>`: a Boolean value
indicating whether this tag separates words
in the text. Once an XML document is
converted to RDF-standoff the markup is
stripped from the text, possibly leading to
continuous text that has been separated by
tags before. For structural tags like
paragraphs etc., `<separatesWords>` can be
set to `true` in which case a special
separator is inserted in the the text in the
RDF representation. In this way, words stay
separated and are represented in the
fulltext index as such.

- `<standoffClass>`: information about the
standoff class the XML element is mapped to

- `<classIri>`: Iri of the standoff class the
XML element is mapped to

- `<attributes>`: XML attributes to be
mapped to standoff properties (other
than `id` or `class`), if any

- `<attribute>`: an XML attribute
to be mapped to a standoff
property, may be repeated

- `<attributeName>`: the name
of the XML attribute
- `<namespace>`: the namespace
the attribute belongs to, if
any. If the attribute does
not belong to a namespace,
the keyword `noNamespace`
has to be used.
- `<propertyIri>`: the Iri of
the standoff property the
XML attribute is mapped to.

- `<datatype>`: the data type of the
standoff class, if any.

- `<type>`: the Iri of the data type
standoff class
- `<attributeName>`: the name of the
attribute holding the typed value in
the expected Knora standard format

XML structure of a mapping:

Expand Down Expand Up @@ -254,32 +254,32 @@ sense to make the corresponding standoff property required
Knora allows the use of all its value types as standoff data types
(defined in `knora-base.ttl`):

- `knora-base:StandoffLinkTag`: Represents a reference to a Knora
resource (the IRI of the target resource must be submitted in the
data type attribute).
- `knora-base:StandoffInternalReferenceTag`: Represents an internal
reference inside a document (the id of the target element inside the
same document must be indicated in the data type attribute); see
[Internal References in an XML Document](#internal-references-in-an-xml-document).
- `knora-base:StandoffUriTag`: Represents a reference to a URI (the
URI of the target resource must be submitted in the data type
attribute).
- `knora-base:StandoffDateTag`: Represents a date (a Knora date
string must be submitted in the data type attribute, e.g.
`GREGORIAN:2017-01-27`).
- `knora-base:StandoffColorTag`: Represents a color (a hexadecimal
RGB color string must be submitted in the data type attribute, e.g.
`#0000FF`).
- `knora-base:StandoffIntegerTag`: Represents an integer (the integer
must be submitted in the data type attribute).
- `knora-base:StandoffDecimalTag`: Represents a number with fractions
(the decimal number must be submitted in the data type attribute,
e.g. `1.1`).
- `knora-base:StandoffIntervalTag`: Represents an interval (two
decimal numbers separated with a comma must be submitted in the data
type attribute, e.g. `1.1,2.2`).
- `knora-base:StandoffBooleanTag`: Represents a Boolean value (`true`
or `false` must be submitted in the data type attribute).
- `knora-base:StandoffLinkTag`: Represents a reference to a Knora
resource (the IRI of the target resource must be submitted in the
data type attribute).
- `knora-base:StandoffInternalReferenceTag`: Represents an internal
reference inside a document (the id of the target element inside the
same document must be indicated in the data type attribute); see
[Internal References in an XML Document](#internal-references-in-an-xml-document).
- `knora-base:StandoffUriTag`: Represents a reference to a URI (the
URI of the target resource must be submitted in the data type
attribute).
- `knora-base:StandoffDateTag`: Represents a date (a Knora date
string must be submitted in the data type attribute, e.g.
`GREGORIAN:2017-01-27`).
- `knora-base:StandoffColorTag`: Represents a color (a hexadecimal
RGB color string must be submitted in the data type attribute, e.g.
`#0000FF`).
- `knora-base:StandoffIntegerTag`: Represents an integer (the integer
must be submitted in the data type attribute).
- `knora-base:StandoffDecimalTag`: Represents a number with fractions
(the decimal number must be submitted in the data type attribute,
e.g. `1.1`).
- `knora-base:StandoffIntervalTag`: Represents an interval (two
decimal numbers separated with a comma must be submitted in the data
type attribute, e.g. `1.1,2.2`).
- `knora-base:StandoffBooleanTag`: Represents a Boolean value (`true`
or `false` must be submitted in the data type attribute).

The basic idea is that parts of a text can be marked up in a way that
allows using Knora's built-in data types. In order to do so, the typed
Expand Down Expand Up @@ -514,11 +514,11 @@ paid to the properties' object constraints.
In the ontology, standoff property literals may have one of the
following `knora-base:objectDatatypeConstraint`:

- `xsd:string`
- `xsd:integer`
- `xsd:boolean`
- `xsd:decimal`
- `xsd:anyURI`
- `xsd:string`
- `xsd:integer`
- `xsd:boolean`
- `xsd:decimal`
- `xsd:anyURI`

In XML, all attribute values are submitted as strings. However, these
string representations need to be convertible to the types defined in
Expand Down
15 changes: 13 additions & 2 deletions knora-ontologies/knora-base.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

:attachedToProject knora-admin:SystemProject ;

:ontologyVersion "PR 1372" .
:ontologyVersion "PR 1440" .



Expand Down Expand Up @@ -72,7 +72,6 @@
:objectDatatypeConstraint xsd:boolean .



### http://www.knora.org/ontology/knora-base#objectCannotBeMarkedAsDeleted

:objectCannotBeMarkedAsDeleted rdf:type rdf:Property ;
Expand Down Expand Up @@ -837,6 +836,18 @@
:subjectClassConstraint :StandoffTag .


### http://www.knora.org/ontology/knora-base#targetHasOriginalXMLID

# This property is generated by a SPARQL CONSTRUCT query, it is not used in the triplestore and not used in the API

:targetHasOriginalXMLID rdf:type owl:DatatypeProperty ;

rdfs:subPropertyOf :objectCannotBeMarkedAsDeleted ;

:objectDatatypeConstraint xsd:string ;

:subjectClassConstraint :StandoffTag .


### http://www.knora.org/ontology/knora-base#valueHasStandoff

Expand Down
16 changes: 16 additions & 0 deletions knora-ontologies/standoff-data.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<http://rdfh.ch/standoff/mappings/StandardMapping/elements/wl8QpeAmSrukY1KEdEqN6Q> ,
<http://rdfh.ch/standoff/mappings/StandardMapping/elements/9f0iFk1JTu-gsMHtyUZqcg> ,
<http://rdfh.ch/standoff/mappings/StandardMapping/elements/ODwo82ZLRsiWBVXvipRk1w> ,
<http://rdfh.ch/standoff/mappings/StandardMapping/elements/RKhuK-_tRR60DfQEuH-r1Q> ,

#### additional elements

Expand Down Expand Up @@ -160,6 +161,21 @@
knora-base:mappingHasStandoffClass knora-base:StandoffLinkTag ;
knora-base:mappingHasXMLAttributename "href"^^xsd:string .

<http://rdfh.ch/standoff/mappings/StandardMapping/elements/RKhuK-_tRR60DfQEuH-r1Q>
a knora-base:MappingElement ;
knora-base:mappingHasStandoffClass knora-base:StandoffInternalReferenceTag ;
knora-base:mappingHasXMLClass "internal-link" ;
knora-base:mappingHasXMLNamespace "noNamespace" ;
knora-base:mappingElementRequiresSeparator false ;
knora-base:mappingHasXMLTagname "a" ;
knora-base:mappingHasStandoffDataTypeClass <http://rdfh.ch/standoff/mappings/StandardMapping/elements/Yf-leJ6PRK2dc79yoaZwCQ> .

<http://rdfh.ch/standoff/mappings/StandardMapping/elements/Yf-leJ6PRK2dc79yoaZwCQ>
a knora-base:MappingStandoffDataTypeClass ;
knora-base:mappingHasStandoffClass knora-base:StandoffInternalReferenceTag ;
knora-base:mappingHasXMLAttributename "href" .


###################### additional elements

<http://rdfh.ch/standoff/mappings/StandardMapping/elements/6FnEh0eXQa-iVsU_-QHwBA>
Expand Down
Loading