Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Commit 22a73b9

Browse files
authored
Update README.md to document XML literals (fixes #88)
1 parent 6095412 commit 22a73b9

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,39 @@ The example above results in new RDF node with an IRI composed of the default na
138138
If a default model namespace is not provided in the `.rdfres` file, the resource will fall back to the blank prefix `PREFIX : <URI>` in the RDF model.
139139
The last resort is to let Jena decide, which will use the URI that the RDF model was loaded from.
140140

141+
### Working with RDF XML literals
142+
143+
RDF supports defining [XML literals](https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-XML-literals), whose content is an XML document fragment.
144+
These are parsed by the underlying Jena library as instances of [DocumentElement](https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/DocumentFragment.html).
145+
146+
If you need to deserialise a property whose values will be XML literals, we recommend defining in your metamodel an EMF `EDataType` whose `instanceClassName` is DocumentFragment.
147+
You can then use it as the data type of any relevant attribute.
148+
For example, in the [Eclipse Emfatic](https://eclipse.dev/emfatic/) notation, it would look like this:
149+
150+
```
151+
datatype EXMLLiteral : org.w3c.dom.DocumentFragment;
152+
153+
class Requirement {
154+
attr EXMLLiteral title;
155+
}
156+
```
157+
158+
In modularised Java codebases, accessing this feature from Epsilon may cause an error message like this:
159+
160+
```
161+
module java.xml does not "exports com.sun.org.apache.xerces.internal.dom" to unnamed module
162+
```
163+
164+
In this case, you may need a flag like the following to your JVM options:
165+
166+
```
167+
--add-opens=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED
168+
```
169+
141170
## Converting an XMI file to RDF formats
142171

143172
The "Developer Tools for RDF binding for EMF" feature includes converters from XMI to the [Turtle](https://www.w3.org/TR/turtle/) and [N-Triples](https://www.w3.org/TR/n-triples/) serialisation formats for RDF.
144173

145174
To use them, right-click on a file with the `.xmi` or `.model` extensions in the Eclipse "Project Explorer" or "Package Explorer" views, and select the appropriate option:
146175

147-
![Screenshot showing the conversion options](./images/convert-to-rdf.png)
176+
![Screenshot showing the conversion options](./images/convert-to-rdf.png)

0 commit comments

Comments
 (0)