Skip to content

Commit 79e6668

Browse files
committed
Fix support for Namespace URN syntax
1 parent 95aa731 commit 79e6668

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/RdfUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public static void cleanPrefixes( final Model model ) {
118118
.map( Statement::getSubject )
119119
.filter( Resource::isURIResource )
120120
.map( Resource::getURI )
121+
.map( uri -> uri.endsWith( "#" ) ? uri.replace( "#", "" ) : uri )
121122
.map( AspectModelUrn::fromUrn )
122123
.findAny()
123124
.ifPresent( urn -> model.setNsPrefix( "", urn.getUrnPrefix() ) );

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/ModelElementFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ private static Optional<AspectModelUrn> getUrn( final Resource modelElement ) {
257257
}
258258
return Optional.empty();
259259
}
260-
return Optional.of( AspectModelUrn.fromUrn( modelElement.getURI() ) );
260+
return modelElement.getURI().endsWith( "#" )
261+
? Optional.of( AspectModelUrn.fromUrn( modelElement.getURI().replace( "#", "" ) ) )
262+
: Optional.of( AspectModelUrn.fromUrn( modelElement.getURI() ) );
261263
}
262264

263265
/**

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/serializer/PrettyPrinter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,9 @@ public Object visitLiteral( final Node_Literal it, final String lex, final Strin
481481
public Object visitURI( final Node_URI it, final String uri ) {
482482
final String suri = model.shortForm( uri );
483483
if ( uri.equals( suri ) ) {
484-
return "<" + uri + ">";
484+
return uri.startsWith( "urn:samm:" ) && !uri.contains( "#" )
485+
? "<" + uri + "#>"
486+
: "<" + uri + ">";
485487
} else {
486488
return suri;
487489
}

core/esmf-test-aspect-models/src/main/resources/valid/org.eclipse.esmf.test/1.0.0/AspectWithNamespaceDescription.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1616
@prefix unit: <urn:samm:org.eclipse.esmf.samm:unit:2.2.0#> .
1717

18-
<urn:samm:org.eclipse.esmf.test:1.0.0> a samm:Namespace ;
18+
: a samm:Namespace ;
1919
samm:preferredName "Test namespace"@en ;
2020
samm:description "Test of the namespace pseudo element"@en ;
2121
samm:see <http://example.com/> .

0 commit comments

Comments
 (0)