You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "afs (via GitHub)" <gi...@apache.org> on 2024/05/17 18:05:01 UTC

[PR] GH-2473: Accept rdf:parseType="Statements" [jena]

afs opened a new pull request, #2477:
URL: https://github.com/apache/jena/pull/2477

   `rdf:parseType="Statements"` is used by CIM - see #2473 for details.
   
   This PR adds support (with a warning) for `rdf:parseType="Statements"`.
   
   ----
   
    - [x] Tests are included.
    - [ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/)
    - [x] Commits have been squashed to remove intermediate development commit messages.
    - [x] Key commit messages start with the issue number (GH-xxxx)
   
   By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs merged PR #2477:
URL: https://github.com/apache/jena/pull/2477


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on code in PR #2477:
URL: https://github.com/apache/jena/pull/2477#discussion_r1605465987


##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRDFXML_StAX_EV.java:
##########
@@ -638,9 +637,15 @@ private XMLEvent propertyElementProcess(Node subject, StartElement startElt, Cou
         }
 
         String parseTypeName = parseType;
-        if ( parseTypeName.equals(parseTypeLiteralAlt) ) {
-            Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-            parseTypeName = "Literal";
+        switch( parseTypeName) {
+            case parseTypeLiteralAlt -> {
+                RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", location);

Review Comment:
   Should the second part of the error message be `Treated as rdf:parseType='Literal'`? Just checking because `rdf:parseType='literal'` appears twice in the message....



##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRDFXML_SAX.java:
##########
@@ -1042,15 +1040,21 @@ private String xmlLang(Attributes attributes, Position position) {
         return langStr;
     }
 
-
     private ObjectParseType objectParseType(String parseTypeStr, Position position) {
         if ( parseTypeStr == null )
             return ObjectParseType.Plain;
         try {
             String parseTypeName = parseTypeStr;
-            if ( parseTypeName.equals("literal") ) {
-                Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-                parseTypeName = "Literal";
+            switch(parseTypeName) {
+                case "literal" -> {
+                    RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", position);
+                    parseTypeName = "Literal";
+                }
+                // CIM (Common Information Model) - see github issue 2473
+                case "Statements" -> {
+                    RDFXMLparseWarning("Encountered rdf:parseType='Statements'. Treated as rdf:parseType='literal'", position);
+                    parseTypeName = "Literal";

Review Comment:
   Same question as below... I think it's confusing that `rdf:parseType='literal'` appears so many times in the error message. I expected at least one more option/value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2477:
URL: https://github.com/apache/jena/pull/2477#discussion_r1605542395


##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRDFXML_StAX_EV.java:
##########
@@ -638,9 +637,15 @@ private XMLEvent propertyElementProcess(Node subject, StartElement startElt, Cou
         }
 
         String parseTypeName = parseType;
-        if ( parseTypeName.equals(parseTypeLiteralAlt) ) {
-            Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-            parseTypeName = "Literal";
+        switch( parseTypeName) {
+            case parseTypeLiteralAlt -> {
+                RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", location);

Review Comment:
   Good catch!
   The correct form (standard) is `rdf:parseType='Literal'` (Uppercase-L).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2477:
URL: https://github.com/apache/jena/pull/2477#discussion_r1605542395


##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRDFXML_StAX_EV.java:
##########
@@ -638,9 +637,15 @@ private XMLEvent propertyElementProcess(Node subject, StartElement startElt, Cou
         }
 
         String parseTypeName = parseType;
-        if ( parseTypeName.equals(parseTypeLiteralAlt) ) {
-            Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-            parseTypeName = "Literal";
+        switch( parseTypeName) {
+            case parseTypeLiteralAlt -> {
+                RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", location);

Review Comment:
   Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "arne-bdt (via GitHub)" <gi...@apache.org>.
arne-bdt commented on code in PR #2477:
URL: https://github.com/apache/jena/pull/2477#discussion_r1605539624


##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRDFXML_SAX.java:
##########
@@ -1042,15 +1040,21 @@ private String xmlLang(Attributes attributes, Position position) {
         return langStr;
     }
 
-
     private ObjectParseType objectParseType(String parseTypeStr, Position position) {
         if ( parseTypeStr == null )
             return ObjectParseType.Plain;
         try {
             String parseTypeName = parseTypeStr;
-            if ( parseTypeName.equals("literal") ) {
-                Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-                parseTypeName = "Literal";
+            switch(parseTypeName) {
+                case "literal" -> {
+                    RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", position);
+                    parseTypeName = "Literal";
+                }
+                // CIM (Common Information Model) - see github issue 2473
+                case "Statements" -> {
+                    RDFXMLparseWarning("Encountered rdf:parseType='Statements'. Treated as rdf:parseType='literal'", position);
+                    parseTypeName = "Literal";

Review Comment:
   I think this is incorrect. The original `if (parseTypeName.equals("literal")) {` should only issue a warning if someone accidentally wrote 'Literal' in lowercase. Therefore, if we extend the same logic to 'Statements', the case should be written in lowercase as 'statements', and the warning should be: 'Encountered rdf:parseType="statements". Treated as rdf:parseType="Literal."



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "arne-bdt (via GitHub)" <gi...@apache.org>.
arne-bdt commented on code in PR #2477:
URL: https://github.com/apache/jena/pull/2477#discussion_r1605539624


##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRDFXML_SAX.java:
##########
@@ -1042,15 +1040,21 @@ private String xmlLang(Attributes attributes, Position position) {
         return langStr;
     }
 
-
     private ObjectParseType objectParseType(String parseTypeStr, Position position) {
         if ( parseTypeStr == null )
             return ObjectParseType.Plain;
         try {
             String parseTypeName = parseTypeStr;
-            if ( parseTypeName.equals("literal") ) {
-                Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-                parseTypeName = "Literal";
+            switch(parseTypeName) {
+                case "literal" -> {
+                    RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", position);
+                    parseTypeName = "Literal";
+                }
+                // CIM (Common Information Model) - see github issue 2473
+                case "Statements" -> {
+                    RDFXMLparseWarning("Encountered rdf:parseType='Statements'. Treated as rdf:parseType='literal'", position);
+                    parseTypeName = "Literal";

Review Comment:
   I think this is incorrect. The original `if (parseTypeName.equals("literal")) {` should only issue a warning if someone accidentally wrote 'Literal' in lowercase. Therefore, if we extend the same logic to 'Statements', the case should be written in lowercase as 'statements', and the warning should be: 'Encountered rdf:parseType="statements". Treated as rdf:parseType="Literal."



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-2473: Accept rdf:parseType="Statements" [jena]

Posted by "kinow (via GitHub)" <gi...@apache.org>.
kinow commented on code in PR #2477:
URL: https://github.com/apache/jena/pull/2477#discussion_r1605548712


##########
jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRDFXML_StAX_EV.java:
##########
@@ -638,9 +637,15 @@ private XMLEvent propertyElementProcess(Node subject, StartElement startElt, Cou
         }
 
         String parseTypeName = parseType;
-        if ( parseTypeName.equals(parseTypeLiteralAlt) ) {
-            Log.warn(SysRIOT.getLogger(), "Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'");
-            parseTypeName = "Literal";
+        switch( parseTypeName) {
+            case parseTypeLiteralAlt -> {
+                RDFXMLparseWarning("Encountered rdf:parseType='literal'. Treated as rdf:parseType='literal'", location);

Review Comment:
   Looks good to me now, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org