Skip to content

Commit

Permalink
fixup! fixup! Fix Resolve Schema Location for xsi:SchemaLocation in C…
Browse files Browse the repository at this point in the history
…onfig files

- add comment explaining systemIdPath check change

DAFFODIL-2339
  • Loading branch information
olabusayoT committed Oct 15, 2024
1 parent 6137cf8 commit 16dcd8c
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,40 @@ class DFDLCatalogResolver private ()
// because the nsURI will resolve to the including schema file.
// This will cause the including schema to be repeatedly parsed resulting in a stack overflow.

lazy val systemIdUri = if (systemId != null) {
new URI(systemId)
} else {
null
}
/**
* Xerces has a bug where it aboslutizes systemId. i.e the user supplies
* {{{
* <xs:schema...
* ... xsi:schemaLocation="urn:some:namespace /some/path.xsd"
* }}}
* Xerces takes that schemaLocation path and absolutizes it to file:/some/path.xsd
* and passes that to our resolveEntity, which while it's able to find the namespace,
* fails to set the resolvedUri since the file:/some/path.xsd will never match anything
* resolved from our catalog since that'd return something like
* file:/some/absolute/path/to/some/path.xsd.
*
* This is a workaround to that bug where we convert systemId to a URI and check if the
* path (from URI.getPath) matches the end of resolvedUri. Note: This can ignore absolute
* URIs passed in for schemaLocation, but those are edge cases where the user expects
* the namespace to match a different file (i.e what they provide in the schemalocation)
* than what we find in the catalog.
*/
lazy val systemIdPath = if (systemIdUri != null && systemIdUri.getScheme == "file") {
systemIdUri.getPath
} else {
systemId
}
val resolvedId = {
if (resolvedSystem != null && resolvedSystem != resolvedUri) {
resolvedSystem
} else if (
resolvedUri != null && ((systemId == null) || (systemId != null && resolvedUri.endsWith(
(new URI(systemId)).getPath
systemIdPath
)))
) {
resolvedUri
Expand Down

0 comments on commit 16dcd8c

Please sign in to comment.