Compiled Apache Xerces2 Java 2.12.2 with the following changes. 

Used: Java 1.8. Ran: rm -rf ./build ; build.sh jars

* Incorrect xml:base in some cases. Example:
------------------------------------------------------------------------------
XercesXIncludeBug/:
a.xml  b/

XercesXIncludeBug/b:
b.xml  c/

XercesXIncludeBug/b/c:
c.xml


a.xml includes b.xml which includes c.xml.

Without the patch, we have transcluded a.xml where
<c> has incorrect xml:base="b/c/c.xml":
---
<a>
    <b xml:base="b/b.xml">
        <c xml:base="b/c/c.xml">Text</c>
    </b>
</a>
---

With the patch, we have transcluded a.xml where
<c> has incorrect xml:base="c/c.xml":
---
<a>
    <b xml:base="b/b.xml">
        <c xml:base="c/c.xml">Text</c>
    </b>
</a>
---
------------------------------------------------------------------------------

src/org/apache/xerces/xinclude/XIncludeHandler.java
------------------------------------------------------------------------------
--- XIncludeHandler.java.ORI	2022-01-21 01:21:00.000000000 +0100
+++ XIncludeHandler.java	2022-11-19 10:40:41.302170514 +0100
@@ -2150,7 +2150,7 @@
                 }
 
                 URI base = new URI(fParentRelativeURI, true);
-                URI uri = new URI(base, relativeURI);
+                URI uri = new URI(relativeURI, true);
                 
                 /** Check whether the scheme components are equal. */
                 final String baseScheme = base.getScheme();
------------------------------------------------------------------------------

* No built-in support for xml:id by the XInclude implementation.

src/org/apache/xerces/xpointer/ShortHandPointer.java
------------------------------------------------------------------------------
--- ShortHandPointer.java.ORI	2022-01-21 01:21:00.000000000 +0100
+++ ShortHandPointer.java	2022-11-19 10:46:09.038118618 +0100
@@ -159,7 +159,13 @@
                 if (normalizedValue != null) {
                     break;
                 }
-                // 4. No externally determined ID's
+
+                // 4. Use xml:id ---
+                
+                if ("xml:id".equals(attributes.getQName(i))) {
+                    normalizedValue = attributes.getValue(i).trim();
+                    break;
+                }
             }
         }
         
@@ -291,4 +297,4 @@
     public void setSchemeData(String schemeData) {
         // NA
     }
-}
\ No newline at end of file
+}
------------------------------------------------------------------------------
