From e5851a76ccb03e76285d4f25db55125b3b37bf0b Mon Sep 17 00:00:00 2001 From: olabusayoT <50379531+olabusayoT@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:15:09 -0400 Subject: [PATCH] Fix Resolve Schema Location for xsi:SchemaLocation in Config files - currently, due to a bug in Xerces xsi:schemaLocation URIs are absolutized, which causes resolveCommon to not set the resolvedUri to the path it resolves from namespace, since the absolute URI doesn't match the end of the resolvedURI. This fix converts systemId to a URI and uses its path when comparing with resolvedURI, therefore resulting in a successful resolution. - add comment explaining systemIdPath check change - add schema location to config to prove it doesn't cause failure DAFFODIL-2339 --- .../daffodil/lib/xml/DaffodilXMLLoader.scala | 34 +++++++++++++++++-- .../daffodil_config_cli_test.xml | 24 +++---------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/DaffodilXMLLoader.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/DaffodilXMLLoader.scala index 68f7645f83..34eb2fda51 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/DaffodilXMLLoader.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/DaffodilXMLLoader.scala @@ -216,12 +216,41 @@ 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 absolutizes systemId i.e the user supplies + * {{{ + * - - - + -9