ohkwon79 commented on code in PR #617:
URL: https://github.com/apache/poi/pull/617#discussion_r1571551590


##########
poi-ooxml/src/test/java/org/apache/poi/openxml4j/opc/TestRelationships.java:
##########
@@ -323,10 +323,10 @@ private void assert_50154(OPCPackage pkg) throws 
Exception {
 
         PackageRelationship rId1 = drawingPart.getRelationship("rId1");
         URI parent = drawingPart.getPartName().getURI();
-        URI rel1 = parent.relativize(rId1.getTargetURI());
-        URI rel11 = 
PackagingURIHelper.relativizeURI(drawingPart.getPartName().getURI(), 
rId1.getTargetURI());
-        assertEquals("'Another Sheet'!A1", rel1.getFragment());
-        assertEquals("'Another Sheet'!A1", rel11.getFragment());
+//        URI rel1 = parent.relativize(rId1.getTargetURI());

Review Comment:
   This is because PackageRelationship.getTargetURI() has been modified to not 
resolve based on the source URI in the case of hyperlinks. 
(PackageRelationship.java)
   
   ```
           if 
(PackageRelationshipTypes.HYPERLINK_PART.equals(relationshipType)) {
               return targetUri;
           }
   ```
   
   Because the targetURI of an internal hyperlink is not based on a physical 
file and only has a fragment, it is inappropriate to obtain the absolute path 
through resolve(). So, it does not resolve and returns only the fragment as is.
   
   If targetURI is only a fragment like "#XXX", 
PackagingURIHelper.relativizeURI() returns "../" and thus fails the test. 
parent.relativize() normally returns a URI with only the fragment.
   
   There is also a way to modify PackagingURIHelper.relativizeURI() to properly 
handle URIs with only fragments, like URI.relativize().
   
   However, in my personal opinion, I think that it is inappropriate to 
resolve() or relativize() hyperlink relationships based on sourceURI. That's 
why I commented out this part.



-- 
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: dev-unsubscr...@poi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to