Skip to content

Conversation

@berezovskyi
Copy link
Contributor

Description

Lyo uses XMLLiteral type for XML Literals in RDF when creating extended properties but uses String type for annotated Java properties for the same RDF type. This caused differences in processing of the same content depending on the property name. See https://forum.open-services.net/t/oslc4j-cannot-get-a-changerequest-that-contains-special-characters/492/11

This PR allows you to use XMLLiteral both as an OSLC ValueType and as a Java property type:

    @OslcValueType(ValueType.XMLLiteral)
    public XMLLiteral getDescription() {
        return description;
    }

This may result in more strict handling of the property value. No existing behaviour is expected to change. See #213 for a helper to check if a String contains valid XML.

Checklist

  • This PR adds an entry to the CHANGELOG. See https://keepachangelog.com/en/1.0.0/ for instructions. Minor edits are exempt. Should add an entry after 4.1 release.
  • This PR was tested on at least one Lyo OSLC server or adds unit/integration tests.
  • This PR does NOT break the API

@berezovskyi
Copy link
Contributor Author

We did a screenshare review with Jad. The question is if we want to include it in Lyo 4.1 release. I would suggest to keep it for 4.2/5.0.

@jadelkhoury
Copy link
Contributor

I also vote to wait. Then we can use and test it a bit more

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.3% 0.3% Duplication

@berezovskyi berezovskyi added this to the 5.1 milestone May 9, 2022
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
0.3% 0.3% Duplication

@github-actions github-actions bot force-pushed the xml-literals branch 6 times, most recently from 899ef98 to 46c1f5c Compare May 2, 2023 07:43
@github-actions github-actions bot force-pushed the xml-literals branch 2 times, most recently from 6a0b161 to fd9b6b8 Compare May 24, 2023 07:43
@github-actions github-actions bot force-pushed the xml-literals branch 4 times, most recently from 857a0f8 to d82b6df Compare June 21, 2023 07:43
@berezovskyi berezovskyi modified the milestones: 5.1, 5.2 Jun 30, 2023
@berezovskyi berezovskyi changed the title Handle XMLLiteral Java type feat: Handle XMLLiteral Java type Jun 30, 2023
@berezovskyi
Copy link
Contributor Author

From the run output:

Error:  Errors: 
Error:    XmlLiteralTest.literalTestXmlDatatypeRDF:158->readModel:186 » Riot [line: 5, col: 33] {E211} Base URI is null, but there are relative URIs to resolve.: <>
Error:    XmlLiteralTest.literalTestXmlDatatypeXSD:143->readModel:186 » Riot [line: 5, col: 33] {E211} Base URI is null, but there are relative URIs to resolve.: <>
Error:    XmlLiteralTest.literalTestXmlParsetype:171->readModel:186 » Riot [line: 5, col: 33] {E211} Base URI is null, but there are relative URIs to resolve.: <>
Error:    XmlLiteralTest.roundtripTestXmlDatatypeRDF:54->readModel:186 » Riot [line: 5, col: 33] {E211} Base URI is null, but there are relative URIs to resolve.: <>
Error:    XmlLiteralTest.roundtripTestXmlParsetypeWithAnnotatedLiteralProperty:62->readModel:186 » Riot [line: 6, col: 33] {E211} Base URI is null, but there are relative URIs to resolve.: <>
Error:    XmlLiteralTest.roundtripTestXmlParsetypeWithAnnotatedStringProperty:70->readModel:186 » Riot [line: 6, col: 33] {E211} Base URI is null, but there are relative URIs to resolve.: <>
[INFO] 
Error:  Tests run: 216, Failures: 0, Errors: 6, Skipped: 65

I believe the errors were introduced not due to changes on master in the meantime but due to a more strict RDF parsing in newer Jena versions.

@berezovskyi
Copy link
Contributor Author

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Jul 16, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl ✅ Pass completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server ✅ Pass completed Link

Copilot AI review requested due to automatic review settings December 13, 2025 16:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for using XMLLiteral as both an OSLC ValueType and a Java property type, resolving inconsistencies in how Lyo handles XML Literals in RDF. Previously, Lyo used the XMLLiteral type for extended properties but required String type for annotated Java properties, causing processing differences based on property naming.

  • Added XMLLiteral to the class-to-valuetype mapping in ResourceShapeFactory
  • Implemented marshaling and unmarshaling support for XMLLiteral properties in JenaModelHelper
  • Added comprehensive test coverage with multiple RDF serialization formats

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/model/ResourceShapeFactory.java Maps XMLLiteral class to ValueType.XMLLiteral and updates validation to accept both String and XMLLiteral for XMLLiteral value types
core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/JenaModelHelper.java Adds marshaling and unmarshaling logic for XMLLiteral properties
core/oslc4j-core/src/test/java/org/eclipse/lyo/oslc4j/core/model/ResourceShapeFactoryTest.java Adds unit tests for XMLLiteral type validation
core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/XmlLiteralTest.java Comprehensive test suite for XMLLiteral handling across different RDF formats
core/oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/resources/TestResourceWithLiterals.java Test resource with both XMLLiteral and String properties annotated with XMLLiteral value type
core/oslc4j-jena-provider/src/test/resources/xml_literals/*.{ttl,rdf} Test data covering valid and invalid XMLLiteral scenarios
trs/server/src/test/resources/simplelogger.properties Updated logging configuration for more detailed test output
trs/client/trs-client/src/test/resources/simplelogger.properties Updated logging configuration for more detailed test output
core/oslc4j-jena-provider/src/test/resources/simplelogger.properties New logging configuration for test output
.editorconfig Added max_line_length settings for code formatting consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Test(expected = RiotException.class)
public void invalidLiteralTest_BadXml() {
final Model diskModel =
readModel("/xml_literals/invalid_badxml.rdf", RDFLanguages.strLangTurtle);
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RDF language constant is incorrect. The file path indicates an RDF/XML file (invalid_badxml.rdf), but the code uses RDFLanguages.strLangTurtle. This should be RDFLanguages.strLangRDFXML to correctly parse the RDF/XML format.

Suggested change
readModel("/xml_literals/invalid_badxml.rdf", RDFLanguages.strLangTurtle);
readModel("/xml_literals/invalid_badxml.rdf", RDFLanguages.strLangRDFXML);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants