You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2021/02/08 17:02:36 UTC

[GitHub] [jena] afs opened a new pull request #916: JENA-2039: Fix and tests (IRI handling), and more IRI cleanup (JENA-2031)

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


   


----------------------------------------------------------------
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.

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


[GitHub] [jena] afs merged pull request #916: JENA-2039: Fix and tests (IRI handling), and more IRI cleanup (JENA-2031)

Posted by GitBox <gi...@apache.org>.
afs merged pull request #916:
URL: https://github.com/apache/jena/pull/916


   


----------------------------------------------------------------
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.

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


[GitHub] [jena] afs commented on a change in pull request #916: JENA-2039: Fix and tests (IRI handling), and more IRI cleanup (JENA-2031)

Posted by GitBox <gi...@apache.org>.
afs commented on a change in pull request #916:
URL: https://github.com/apache/jena/pull/916#discussion_r572230641



##########
File path: jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java
##########
@@ -21,44 +21,38 @@
 
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
-import org.apache.jena.iri.IRI ;
 import org.apache.jena.riot.checker.* ;
+import org.apache.jena.sparql.core.Quad;
 
-/** A checker validates RDF terms. */
+/** A checker that drives the process of validating RDF terms, triples and quads. */
 public final class Checker
 {
     private boolean allowRelativeIRIs = false ;
     private boolean warningsAreErrors = false ;
     private ErrorHandler handler ;
-    
+
     private NodeChecker checkLiterals ;
     private NodeChecker checkURIs ;
     private NodeChecker checkBlankNodes ;
     private NodeChecker checkVars ;
 
-    public Checker()
-    {
-        this(null) ;
+    public Checker() {
+        this(null);
     }
-    
-    public Checker(ErrorHandler handler)
-    {
+
+    public Checker(ErrorHandler handler) {
         if ( handler == null )
-            handler = ErrorHandlerFactory.getDefaultErrorHandler() ;
-        this.handler = handler ;
-        
-        checkLiterals = new CheckerLiterals(handler) ;
-       
-        checkURIs = new CheckerIRI(handler, IRIResolver.iriFactory()) ;
-        checkBlankNodes = new CheckerBlankNodes(handler) ;
-        checkVars = new CheckerVar(handler) ;        
-    }
-
-    public ErrorHandler getHandler()                { return handler ; } 
-    public void setHandler(ErrorHandler handler)    { this.handler = handler ; }
-    
-    public boolean check(Node node, long line, long col)
-    {
+            handler = ErrorHandlerFactory.getDefaultErrorHandler();

Review comment:
       Will fix directly along with some clearing up.




----------------------------------------------------------------
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.

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


[GitHub] [jena] kinow commented on a change in pull request #916: JENA-2039: Fix and tests (IRI handling), and more IRI cleanup (JENA-2031)

Posted by GitBox <gi...@apache.org>.
kinow commented on a change in pull request #916:
URL: https://github.com/apache/jena/pull/916#discussion_r572216319



##########
File path: jena-arq/src/main/java/org/apache/jena/riot/checker/CheckerIRI.java
##########
@@ -86,87 +93,42 @@ public static void iriViolations(IRI iri, ErrorHandler errorHandler) {
     /**
      * Process violations on an IRI
      * Calls the errorHandler on all errors and warnings (as warning).
+     * (If checking for relative IRIs, these are sent out as errors.)
      * Assumes error handler throws exceptions on errors if need be
      */
-    public static void iriViolations(IRI iri, ErrorHandler errorHandler,
-                                     boolean allowRelativeIRIs,
-                                     boolean includeIRIwarnings,
-                                     long line, long col) {
+    private static void iriViolations(IRI iri, ErrorHandler errorHandler,
+                                      boolean allowRelativeIRIs,
+                                      boolean includeIRIwarnings,
+                                      long line, long col) {
         if ( !allowRelativeIRIs && iri.isRelative() )
             errorHandler.error("Relative IRI: " + iri, line, col) ;
 
         if ( iri.hasViolation(includeIRIwarnings) ) {
             Iterator<Violation> iter = iri.violations(includeIRIwarnings) ;
 
-            boolean errorSeen = false ;
-            boolean warningSeen = false ;
-
-            // What to finally report.
-            Violation vError = null ;
-            Violation vWarning = null ;
-            Violation xvSub = null ;
-
             for ( ; iter.hasNext() ; ) {
                 Violation v = iter.next() ;
                 int code = v.getViolationCode() ;
                 boolean isError = v.isError() ;
 
-                // Ignore these. They seem to present even if switched off.
-                if ( code == Violation.LOWERCASE_PREFERRED
-                     || code == Violation.PERCENT_ENCODING_SHOULD_BE_UPPERCASE
-                     || code == Violation.SCHEME_PATTERN_MATCH_FAILED )
-                    continue ;
-
                 // Anything we want to reprioritise?
+                // Some jena-iri violations are fully controllable by error.wraning controls

Review comment:
       s/wraning/warning, but not important as it's a code comment (not javadoc)

##########
File path: jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
##########
@@ -29,19 +29,63 @@
 {
     // ---- System-wide IRI Factory.
 
-    /** The IRI checker setup, focused on parsing and languages.
-     *  This is a clean version of jena-iri {@link IRIFactory#iriImplementation()}
-     *  modified to allow unregistered schemes and allow {@code <file:relative>} IRIs.
-     *
-     *  @see IRIFactory
+    private static boolean         showExceptions    = true;
+
+    private static final boolean   ShowResolverSetup = false;
+
+    /**
+     * The IRI checker setup, focused on parsing and languages.
+     * This is a clean version of jena-iri {@link IRIFactory#iriImplementation()}
+     * modified to allow unregistered schemes and allow {@code <file:relative>} IRIs.
      */
     public static IRIFactory iriFactory() {
         return iriFactoryInst;
     }
 
-    private static boolean         showExceptions    = true;
 
-    private static final boolean   ShowResolverSetup = false;
+    /**
+     * An IRIFactory with more detailed warnings.
+     */
+    public static IRIFactory iriCheckerFactory() {
+        return iriCheckerInst;
+    }
+
+    private static final IRIFactory iriCheckerInst = new IRIFactory();
+    static {
+        // These two are from IRIFactory.iriImplementation() ...
+        iriCheckerInst.useSpecificationIRI(true);
+        iriCheckerInst.useSchemeSpecificRules("*", true);
+        // Allow relative references for file: URLs.
+        iriCheckerInst.setSameSchemeRelativeReferences("file");
+
+        setErrorWarning(iriCheckerInst, ViolationCodes.UNREGISTERED_IANA_SCHEME, false, false);
+        setErrorWarning(iriCheckerInst, ViolationCodes.NON_INITIAL_DOT_SEGMENT, false, false);
+
+        // Choices: setting here does not seem to have any effect. See CheckerIRI and IRIProviderJena.
+        setErrorWarning(iriCheckerInst, ViolationCodes.LOWERCASE_PREFERRED, false, true);
+        setErrorWarning(iriCheckerInst, ViolationCodes.PERCENT_ENCODING_SHOULD_BE_UPPERCASE, false, true);
+        setErrorWarning(iriCheckerInst, ViolationCodes.SCHEME_PATTERN_MATCH_FAILED, false, true);
+
+        //setErrorWarning(iriFactoryInst, ViolationCodes.NOT_NFC,  false, false);
+        // NFKC is not mentioned in RDF 1.1. Switch off.
+        setErrorWarning(iriCheckerInst, ViolationCodes.NOT_NFKC, false, false);
+
+        // ** Applies to various unicode blocks.
+        setErrorWarning(iriCheckerInst, ViolationCodes.COMPATIBILITY_CHARACTER, false, true);
+        setErrorWarning(iriCheckerInst, ViolationCodes.UNDEFINED_UNICODE_CHARACTER, false, true);
+        // The set of legal characters depends on the Java version.
+        // If not set, this causes test failures in Turtle and Trig eval tests.
+        setErrorWarning(iriCheckerInst, ViolationCodes.UNASSIGNED_UNICODE_CHARACTER, false, false);
+
+        if ( ShowResolverSetup ) {

Review comment:
       As we are changing it, could/should we also rename it to `showResolverSetup`?

##########
File path: jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java
##########
@@ -21,44 +21,38 @@
 
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
-import org.apache.jena.iri.IRI ;
 import org.apache.jena.riot.checker.* ;
+import org.apache.jena.sparql.core.Quad;
 
-/** A checker validates RDF terms. */
+/** A checker that drives the process of validating RDF terms, triples and quads. */
 public final class Checker
 {
     private boolean allowRelativeIRIs = false ;
     private boolean warningsAreErrors = false ;
     private ErrorHandler handler ;
-    
+
     private NodeChecker checkLiterals ;
     private NodeChecker checkURIs ;
     private NodeChecker checkBlankNodes ;
     private NodeChecker checkVars ;
 
-    public Checker()
-    {
-        this(null) ;
+    public Checker() {
+        this(null);
     }
-    
-    public Checker(ErrorHandler handler)
-    {
+
+    public Checker(ErrorHandler handler) {
         if ( handler == null )
-            handler = ErrorHandlerFactory.getDefaultErrorHandler() ;
-        this.handler = handler ;
-        
-        checkLiterals = new CheckerLiterals(handler) ;
-       
-        checkURIs = new CheckerIRI(handler, IRIResolver.iriFactory()) ;
-        checkBlankNodes = new CheckerBlankNodes(handler) ;
-        checkVars = new CheckerVar(handler) ;        
-    }
-
-    public ErrorHandler getHandler()                { return handler ; } 
-    public void setHandler(ErrorHandler handler)    { this.handler = handler ; }
-    
-    public boolean check(Node node, long line, long col)
-    {
+            handler = ErrorHandlerFactory.getDefaultErrorHandler();

Review comment:
       Extra spaces?




----------------------------------------------------------------
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.

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


[GitHub] [jena] afs commented on a change in pull request #916: JENA-2039: Fix and tests (IRI handling), and more IRI cleanup (JENA-2031)

Posted by GitBox <gi...@apache.org>.
afs commented on a change in pull request #916:
URL: https://github.com/apache/jena/pull/916#discussion_r572230235



##########
File path: jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java
##########
@@ -21,44 +21,38 @@
 
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
-import org.apache.jena.iri.IRI ;
 import org.apache.jena.riot.checker.* ;
+import org.apache.jena.sparql.core.Quad;
 
-/** A checker validates RDF terms. */
+/** A checker that drives the process of validating RDF terms, triples and quads. */
 public final class Checker
 {
     private boolean allowRelativeIRIs = false ;
     private boolean warningsAreErrors = false ;
     private ErrorHandler handler ;
-    
+
     private NodeChecker checkLiterals ;
     private NodeChecker checkURIs ;
     private NodeChecker checkBlankNodes ;
     private NodeChecker checkVars ;
 
-    public Checker()
-    {
-        this(null) ;
+    public Checker() {
+        this(null);
     }
-    
-    public Checker(ErrorHandler handler)
-    {
+
+    public Checker(ErrorHandler handler) {
         if ( handler == null )
-            handler = ErrorHandlerFactory.getDefaultErrorHandler() ;
-        this.handler = handler ;
-        
-        checkLiterals = new CheckerLiterals(handler) ;
-       
-        checkURIs = new CheckerIRI(handler, IRIResolver.iriFactory()) ;
-        checkBlankNodes = new CheckerBlankNodes(handler) ;
-        checkVars = new CheckerVar(handler) ;        
-    }
-
-    public ErrorHandler getHandler()                { return handler ; } 
-    public void setHandler(ErrorHandler handler)    { this.handler = handler ; }
-    
-    public boolean check(Node node, long line, long col)
-    {
+            handler = ErrorHandlerFactory.getDefaultErrorHandler();

Review comment:
       The previous line is `if ( handler == null )` -- the diff doesn't make it very clear, it's decided that's an unchanged line as seval changes happen in the same area.




----------------------------------------------------------------
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.

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