From e02ae7fff4ad7cccadcef2bfc03c17c941704d56 Mon Sep 17 00:00:00 2001 From: Steve Lawrence Date: Tue, 24 Sep 2024 09:11:03 -0400 Subject: [PATCH] Fix how unprefixed QNames are resolved Commit 2590f54ce9 change it so that if no default namespace is defined then an unprefixed QName reference is resolved using the targetNamespace as its namespace. However, this logic was not correct. Instead, we need different logic depending on if the schema containing such a reference is included vs imported. In the former case, we should use the targetNamespace of the including schema. In the latter, we should just use no-namespace. This modifies the logic to add a new 'noPrefixNamespace' member which keeps track of what namespace to use when resolving a unprefixed QName reference using include/import information. This member replaces previous changes of targetNamespace. This found a number of tests where references to defined formats were not actually correct but happened to work due to previously flawed logic. This corrects these tests, and adds additional tests to make sure include/import logic works as expected. Also Found and removed dead code: - Grammar classes do not need to resolve QNames--the ResolvesQNames trait is removed from BasicCompoent which Grammar mixes in. ResolvesQNames is now only mixed into DSOM-level components. This allows removing members related to resolving QNames - Nothing uses resolveExtendedSyntaxRef so it is removed. Instead one should use QName.refQNameFromExtendedSyntax Deprecation/Compatibility: A bug was fixed so Daffodil now correctly handles resolving unprefixed QName references. However, this means that some unprefixed references that relied on the previous incorrect behavior may not resolve anymore. Although there are a number of ways to fix this, defining a namespace prefix and adding that prefix to broken reference should work in all cases. DAFFODIL-2916 --- .../core/dpath/DFDLExpressionParser.scala | 4 +- .../daffodil/core/dpath/Expression.scala | 15 +-- .../core/dsom/CompiledExpression.scala | 18 +-- .../core/dsom/DFDLDefineVariable.scala | 2 +- .../daffodil/core/dsom/RestrictionUnion.scala | 2 +- .../daffodil/core/dsom/SchemaComponent.scala | 2 +- .../core/dsom/SchemaComponentFactory.scala | 5 + .../SchemaDocIncludesAndImportsMixin.scala | 34 +++++ .../grammar/ElementBaseGrammarMixin.scala | 4 +- .../daffodil/core/grammar/GrammarTerm.scala | 3 - .../primitives/PrimitivesExpressions.scala | 18 +-- .../runtime1/ElementBaseRuntime1Mixin.scala | 3 +- .../SchemaComponentRuntime1Mixin.scala | 2 +- .../runtime1/SimpleTypeRuntime1Mixin.scala | 2 +- .../core/runtime1/VariableRuntime1Mixin.scala | 4 +- ...e_a02_targetnamespace_unqualified.dfdl.xsd | 5 +- .../dpath/TestDFDLExpressionEvaluation.scala | 4 +- .../core/dpath/TestDFDLExpressionTree.scala | 4 +- .../test/japi/alwaysInvalid.dfdl.xsd | 2 +- .../apache/daffodil/lib/xml/QNameBase.scala | 122 +++++++----------- .../org/apache/daffodil/lib/xml/QNames.scala | 9 +- .../props/TestGeneratedProperties.scala | 2 +- .../daffodil/runtime1/BasicComponent.scala | 9 +- .../debugger/InteractiveDebugger.scala | 8 +- .../runtime1/dsom/CompiledExpression1.scala | 6 +- .../runtime1/dsom/ExpressionCompiler.scala | 2 +- .../runtime1/processors/RuntimeData.scala | 18 +-- .../src/test/resources/xsd/with-ns-1.dfdl.xsd | 2 +- .../section06/namespaces/cycle_base.dfdl.xsd | 5 +- .../section06/namespaces/cycle_step.dfdl.xsd | 5 +- .../namespaces/generalFormat01.dfdl.xsd | 39 ++++++ .../namespaces/generalFormat02.dfdl.xsd | 41 ++++++ .../namespaces/generalFormat03.dfdl.xsd | 39 ++++++ .../namespaces/generalFormat04.dfdl.xsd | 39 ++++++ .../section06/namespaces/includeImport.tdml | 41 +++++- .../namespaces/multi_base_01.dfdl.xsd | 5 +- .../namespaces/multi_base_02.dfdl.xsd | 5 +- .../namespaces/multi_base_04.dfdl.xsd | 5 +- .../namespaces/multi_base_06_valid.dfdl.xsd | 5 +- .../namespaces/primTypesPrefixes.dfdl.xsd | 2 +- .../section06/namespaces/qname1.dfdl.xsd | 2 +- .../section06/namespaces/qname2.dfdl.xsd | 2 +- .../unordered_namespaces_03.dfdl.xsd | 5 +- .../dfdl_functions/first_schema.dfdl.xsd | 2 +- .../dfdl_functions/home_schema.dfdl.xsd | 2 +- .../dfdl_functions/second_schema.dfdl.xsd | 2 +- .../section06/namespaces/TestNamespaces.scala | 5 + 47 files changed, 389 insertions(+), 173 deletions(-) create mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat01.dfdl.xsd create mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat02.dfdl.xsd create mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat03.dfdl.xsd create mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat04.dfdl.xsd diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/DFDLExpressionParser.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/DFDLExpressionParser.scala index f5041f1a65..da6d39c02b 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/DFDLExpressionParser.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/DFDLExpressionParser.scala @@ -53,7 +53,7 @@ class DFDLPathExpressionParser[T <: AnyRef]( qn: NamedQName, nodeInfoKind: NodeInfo.Kind, namespaces: NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, context: DPathCompileInfo, isEvaluatedAbove: Boolean, host: BasicComponent @@ -231,7 +231,7 @@ class DFDLPathExpressionParser[T <: AnyRef]( def Comp = EqualityComp | NumberComp def TopLevel: Parser[WholeExpression] = ("{" ~> Expr <~ "}") ^^ { xpr => - WholeExpression(nodeInfoKind, xpr, namespaces, targetNamespace, context, host) + WholeExpression(nodeInfoKind, xpr, namespaces, noPrefixNamespace, context, host) } val SuccessAtEnd = Parser { in => Success(in, new CharSequenceReader("")) } diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala index 7d651f8a81..35c1bacad2 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dpath/Expression.scala @@ -23,7 +23,6 @@ import scala.util.{ Failure, Success } import scala.xml.NamespaceBinding import org.apache.daffodil.lib.api.DaffodilTunables -import org.apache.daffodil.lib.api.UnqualifiedPathStepPolicy import org.apache.daffodil.lib.api.WarnID import org.apache.daffodil.lib.equality._ import org.apache.daffodil.lib.exceptions._ @@ -52,8 +51,6 @@ import org.apache.daffodil.runtime1.udf.UserDefinedFunctionService abstract class Expression extends OOLAGHostImpl() with BasicComponent { override lazy val tunable: DaffodilTunables = parent.tunable - override lazy val unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy = - parent.unqualifiedPathStepPolicy override lazy val localSuppressSchemaDefinitionWarnings: Seq[WarnID] = parent.localSuppressSchemaDefinitionWarnings @@ -153,7 +150,7 @@ abstract class Expression extends OOLAGHostImpl() with BasicComponent { lazy val namespaces: NamespaceBinding = parent.namespaces - lazy val targetNamespace: NS = parent.targetNamespace + lazy val noPrefixNamespace: NS = parent.noPrefixNamespace def children: Seq[Expression] @@ -221,7 +218,7 @@ abstract class Expression extends OOLAGHostImpl() with BasicComponent { def resolveRef(qnameString: String): RefQName = { QName - .resolveRef(qnameString, namespaces, targetNamespace, tunable.unqualifiedPathStepPolicy) + .resolveRef(qnameString, namespaces, noPrefixNamespace, tunable.unqualifiedPathStepPolicy) .recover { case _: Throwable => SDE("The prefix of '%s' has no corresponding namespace definition.", qnameString) } @@ -460,14 +457,12 @@ case class WholeExpression( nodeInfoKind: NodeInfo.Kind, ifor: Expression, nsBindingForPrefixResolution: NamespaceBinding, - targetNamespaceArg: NS, + noPrefixNamespaceArg: NS, ci: DPathCompileInfo, host: BasicComponent ) extends Expression { final override lazy val tunable: DaffodilTunables = host.tunable - final override lazy val unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy = - host.unqualifiedPathStepPolicy final override lazy val localSuppressSchemaDefinitionWarnings: Seq[WarnID] = host.localSuppressSchemaDefinitionWarnings @@ -480,7 +475,7 @@ case class WholeExpression( override lazy val namespaces = nsBindingForPrefixResolution - override lazy val targetNamespace = targetNamespaceArg + override lazy val noPrefixNamespace = noPrefixNamespaceArg override def text = ifor.text @@ -835,7 +830,7 @@ sealed abstract class StepExpression(val step: String, val pred: Option[Predicat val e = QName.resolveStep( step, namespaces, - targetNamespace, + noPrefixNamespace, tunable.unqualifiedPathStepPolicy ) e match { diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/CompiledExpression.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/CompiledExpression.scala index 18e6d62136..3dee43b6ae 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/CompiledExpression.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/CompiledExpression.scala @@ -61,7 +61,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { nodeInfoKind: NodeInfo.Kind, exprOrLiteral: String, namespaces: NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, compileInfoWhereExpressionWasLocated: DPathCompileInfo, isEvaluatedAbove: Boolean, host: BasicComponent, @@ -78,7 +78,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { nodeInfoKind, exprOrLiteral, namespaces, - targetNamespace, + noPrefixNamespace, compileInfoWhereExpressionWasLocated, isEvaluatedAbove, host, @@ -90,7 +90,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { nodeInfoKind, exprOrLiteral, namespaces, - targetNamespace, + noPrefixNamespace, compileInfoWhereExpressionWasLocated, isEvaluatedAbove ) @@ -126,7 +126,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { nodeInfoKind, property.value, property.location.namespaces, - property.location.targetNamespace, + property.location.noPrefixNamespace, compileInfo, isEvaluatedAbove, host, @@ -171,7 +171,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { staticNodeInfoKind, exprOrLiteral, namespacesForNamespaceResolution, - property.location.targetNamespace, + property.location.noPrefixNamespace, compileInfoWhereExpressionWasLocated, isEvaluatedAbove, host, @@ -186,7 +186,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { runtimeNodeInfoKind, exprOrLiteral, namespacesForNamespaceResolution, - property.location.targetNamespace, + property.location.noPrefixNamespace, compileInfoWhereExpressionWasLocated, isEvaluatedAbove, host, @@ -219,7 +219,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { nodeInfoKind: NodeInfo.Kind, exprOrLiteral: String, namespaces: NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, compileInfoWhereExpressionWasLocated: DPathCompileInfo, isEvaluatedAbove: Boolean, host: BasicComponent, @@ -239,7 +239,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { qn, nodeInfoKind, namespaces, - targetNamespace, + noPrefixNamespace, compileInfo, isEvaluatedAbove, host @@ -253,7 +253,7 @@ class ExpressionCompiler[T <: AnyRef] extends ExpressionCompilerBase[T] { nodeInfoKind: NodeInfo.Kind, exprOrLiteral: String, namespaces: NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, compileInfoWhereExpressionWasLocated: DPathCompileInfo, isEvaluatedAbove: Boolean ): CompiledExpression[T] = { diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/DFDLDefineVariable.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/DFDLDefineVariable.scala index be82b000d3..e8cbd722e3 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/DFDLDefineVariable.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/DFDLDefineVariable.scala @@ -86,7 +86,7 @@ class DFDLDefineVariable private (node: Node, doc: SchemaDocument) val eQN = QName.resolveRef( typeQNameString, namespaces, - targetNamespace, + noPrefixNamespace, tunable.unqualifiedPathStepPolicy ) val res = eQN.recover { case _: Throwable => diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/RestrictionUnion.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/RestrictionUnion.scala index 2266174edf..75ad733293 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/RestrictionUnion.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/RestrictionUnion.scala @@ -93,7 +93,7 @@ final class Restriction private (xmlArg: Node, val simpleTypeDef: SimpleTypeDefB QName.resolveRef( baseQNameString, xml.scope, - targetNamespace, + noPrefixNamespace, tunable.unqualifiedPathStepPolicy ) schemaDefinitionUnless( diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponent.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponent.scala index 191603e35d..d3d4adaa56 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponent.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponent.scala @@ -94,7 +94,7 @@ trait SchemaComponent Delay('nonElementParents, this, parents), variableMap, namespaces, - targetNamespace, + noPrefixNamespace, path, schemaFileLocation, tunable.unqualifiedPathStepPolicy diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponentFactory.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponentFactory.scala index a80e1800d8..42fe960012 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponentFactory.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaComponentFactory.scala @@ -110,6 +110,11 @@ trait CommonContextMixin extends NestingLexicalMixin with CommonContextView { */ def targetNamespace: NS = xmlSchemaDocument.targetNamespace + /** + * The namespace to use to resolve references without a prefix + */ + def noPrefixNamespace: NS = xmlSchemaDocument.noPrefixNamespace + final lazy val targetNamespacePrefix = xml.scope.getPrefix(targetNamespace.toString) } diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaDocIncludesAndImportsMixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaDocIncludesAndImportsMixin.scala index f682027972..26f2250fd0 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaDocIncludesAndImportsMixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaDocIncludesAndImportsMixin.scala @@ -93,6 +93,40 @@ trait SchemaDocIncludesAndImportsMixin { self: XMLSchemaDocument => resultNS }.value + /** + * when we resolve a QName reference, if that reference does not have a prefix and there is no + * in-scope default namespace, then we use this namespace, which varies depending on things + * like targetNamespace and whether this schema was included or imported + */ + override lazy val noPrefixNamespace: NS = LV('noPrefixNamespace) { + ii match { + case Some(inc: Include) => { + // if this schema document was included in another document, then either the two + // schemas already have the same targetNamespace or this schema has no-namespace and + // is chameleoned into the targetNamespace of the including schema. Either way, the + // resulting included elements are in the targetNamespace and so any unprefixed + // references to those elements should use the including schemas targetNamespace when + // resolving + inc.targetNamespace + } + case Some(imp: Import) => { + // if this schema document was imported and we don't have a default namespace then any + // unprefixed references just resolve to NoNamespace. Note that if this schema has a + // targetNamespace, then it can only reference elements that are imported into it + // without a namespace + NoNamespace + } + case _ => { + // this is either a Some() that isn't an Include/Import, or this is the bootstrap schema + // and we shouldn't be asking for its noPrefixNamespace. Both cases should be + // impossible. + // $COVERAGE-OFF$ + Assert.impossible() + // $COVERAGE-ON$ + } + } + }.value + // There is one distinguished top level SchemaDocument // that we use to start the ball rolling by importing all the // files that the user supplies via the API/command line. diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala index 45d4bf0b3a..d230c94f05 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/ElementBaseGrammarMixin.scala @@ -1485,14 +1485,14 @@ trait ElementBaseGrammarMixin val exprProp = outputValueCalcOption.asInstanceOf[Found] val exprText = exprProp.value val exprNamespaces = exprProp.location.namespaces - val exprTargetNamespace = exprProp.location.targetNamespace + val exprNoPrefixNamespace = exprProp.location.noPrefixNamespace val qn = GlobalQName(Some("daf"), "outputValueCalc", XMLUtils.dafintURI) val expr = ExpressionCompilers.AnyRef.compileExpression( qn, primType, exprText, exprNamespaces, - exprTargetNamespace, + exprNoPrefixNamespace, dpathCompileInfo, isEvaluatedAbove = false, self, diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/GrammarTerm.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/GrammarTerm.scala index d7d5392d66..52f77124b3 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/GrammarTerm.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/GrammarTerm.scala @@ -55,9 +55,6 @@ abstract class Gram(contextArg: SchemaComponent) final override lazy val tunable = context.tunable - final override def namespaces = context.namespaces - final override def targetNamespace = context.targetNamespace - final override def unqualifiedPathStepPolicy = context.unqualifiedPathStepPolicy final override def schemaFileLocation = context.schemaFileLocation final override def localSuppressSchemaDefinitionWarnings = context.localSuppressSchemaDefinitionWarnings diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesExpressions.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesExpressions.scala index 5f1c88d703..76bc170b34 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesExpressions.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/grammar/primitives/PrimitivesExpressions.scala @@ -56,7 +56,7 @@ abstract class AssertBase( decl: AnnotatedSchemaComponent, exprWithBraces: String, namespacesForNamespaceResolution: scala.xml.NamespaceBinding, - targetNamespaceArg: NS, + noPrefixNamespaceArg: NS, scWherePropertyWasLocated: AnnotatedSchemaComponent, msgOpt: Option[String], discrim: Boolean, // are we a discriminator or not. @@ -76,7 +76,7 @@ abstract class AssertBase( decl, foundProp.value, foundProp.location.namespaces, - foundProp.location.targetNamespace, + foundProp.location.noPrefixNamespace, decl, msgOpt, discrim, @@ -87,7 +87,7 @@ abstract class AssertBase( override val baseName = assertKindName override lazy val exprText = exprWithBraces override lazy val exprNamespaces = namespacesForNamespaceResolution - override lazy val exprTargetNamespace = targetNamespaceArg + override lazy val exprNoPrefixNamespace = noPrefixNamespaceArg override lazy val exprComponent = scWherePropertyWasLocated override def nodeKind = NodeInfo.Boolean @@ -100,7 +100,7 @@ abstract class AssertBase( NodeInfo.String, msgOpt.get, exprNamespaces, - exprTargetNamespace, + exprNoPrefixNamespace, exprComponent.dpathCompileInfo, false, this, @@ -202,7 +202,7 @@ case class SetVariable(stmt: DFDLSetVariable, override val term: Term) override lazy val exprText = stmt.value override lazy val exprNamespaces = stmt.xml.scope - override lazy val exprTargetNamespace = stmt.annotatedSC.targetNamespace + override lazy val exprNoPrefixNamespace = stmt.annotatedSC.noPrefixNamespace override lazy val exprComponent = stmt override lazy val nodeKind = stmt.defv.primType @@ -287,7 +287,7 @@ abstract class ExpressionEvaluatorBase(e: AnnotatedSchemaComponent) extends Term def baseName: String def exprNamespaces: scala.xml.NamespaceBinding - def exprTargetNamespace: NS + def exprNoPrefixNamespace: NS def exprComponent: SchemaComponent def exprText: String @@ -301,7 +301,7 @@ abstract class ExpressionEvaluatorBase(e: AnnotatedSchemaComponent) extends Term nodeKind, exprText, exprNamespaces, - exprTargetNamespace, + exprNoPrefixNamespace, exprComponent.dpathCompileInfo, false, this, @@ -315,7 +315,7 @@ abstract class ValueCalcBase(e: ElementBase, property: PropertyLookupResult) override lazy val exprText = exprProp.value override lazy val exprNamespaces = exprProp.location.namespaces - override lazy val exprTargetNamespace = exprProp.location.targetNamespace + override lazy val exprNoPrefixNamespace = exprProp.location.noPrefixNamespace override lazy val exprComponent = exprProp.location.asInstanceOf[SchemaComponent] lazy val pt = e.primType // .typeRuntimeData @@ -344,7 +344,7 @@ abstract class AssertPatternPrimBase(decl: Term, stmt: DFDLAssertionBase, discri override val baseName = if (discrim) "Discriminator" else "Assert" override lazy val exprText = stmt.messageAttrib.get override lazy val exprNamespaces = decl.namespaces - override lazy val exprTargetNamespace = decl.targetNamespace + override lazy val exprNoPrefixNamespace = decl.noPrefixNamespace override lazy val exprComponent = decl override def nodeKind = NodeInfo.String diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/ElementBaseRuntime1Mixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/ElementBaseRuntime1Mixin.scala index f8032f65e4..aa2e6a1dd8 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/ElementBaseRuntime1Mixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/ElementBaseRuntime1Mixin.scala @@ -148,7 +148,7 @@ trait ElementBaseRuntime1Mixin { self: ElementBase => variableMap, Delay('elementChildrenCompileInfo, this, elementChildrenCompileInfo), namespaces, - targetNamespace, + noPrefixNamespace, slashPath, name, isArray, @@ -191,6 +191,7 @@ trait ElementBaseRuntime1Mixin { self: ElementBase => minimizedScope, defaultBitOrder, optPrimType, + targetNamespace, optSimpleTypeRuntimeData, optComplexTypeModelGroupRuntimeData, minOccurs, diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SchemaComponentRuntime1Mixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SchemaComponentRuntime1Mixin.scala index 93461eeb01..d6a60751d1 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SchemaComponentRuntime1Mixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SchemaComponentRuntime1Mixin.scala @@ -43,7 +43,7 @@ trait SchemaComponentRuntime1Mixin { self: SchemaComponent => diagnosticDebugName, path, namespaces, - targetNamespace, + noPrefixNamespace, tunable.unqualifiedPathStepPolicy ) }.value diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SimpleTypeRuntime1Mixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SimpleTypeRuntime1Mixin.scala index f4d5720795..bf6fb3e4f0 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SimpleTypeRuntime1Mixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/SimpleTypeRuntime1Mixin.scala @@ -30,7 +30,7 @@ trait SimpleTypeRuntime1Mixin { self: SimpleTypeDefBase => diagnosticDebugName, path, namespaces, - targetNamespace, + noPrefixNamespace, primType, noFacetChecks, optRestriction.toSeq.flatMap { r => if (r.hasPattern) r.patternValues else Nil }, diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/VariableRuntime1Mixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/VariableRuntime1Mixin.scala index 45698b7409..fbcbf0a454 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/VariableRuntime1Mixin.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/core/runtime1/VariableRuntime1Mixin.scala @@ -40,7 +40,7 @@ trait DFDLDefineVariableRuntime1Mixin { self: DFDLDefineVariable => this.diagnosticDebugName, this.path, this.namespaces, - this.targetNamespace, + this.noPrefixNamespace, this.external, this.direction, Delay('maybeDefaultValueExpr, this, maybeDefaultValueExpr), @@ -94,7 +94,7 @@ trait DFDLNewVariableInstanceRuntime1Mixin { self: DFDLNewVariableInstance => this.diagnosticDebugName, this.path, this.namespaces, - this.targetNamespace, + this.noPrefixNamespace, defv.external, defv.direction, Delay('maybeDefaultValueExpr2, this, maybeDefaultValueExpr), diff --git a/daffodil-core/src/test/resources/test/example_a02_targetnamespace_unqualified.dfdl.xsd b/daffodil-core/src/test/resources/test/example_a02_targetnamespace_unqualified.dfdl.xsd index 04f86aff59..5ebc231081 100644 --- a/daffodil-core/src/test/resources/test/example_a02_targetnamespace_unqualified.dfdl.xsd +++ b/daffodil-core/src/test/resources/test/example_a02_targetnamespace_unqualified.dfdl.xsd @@ -18,13 +18,14 @@ + xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" + xmlns:a2="http://a02.com"> - - + diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNameBase.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNameBase.scala index 879d58a2b0..b14b6047a8 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNameBase.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNameBase.scala @@ -111,10 +111,10 @@ object QName { def resolveRef( qnameString: String, scope: scala.xml.NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy ): Try[RefQName] = - RefQNameFactory.resolveRef(qnameString, scope, targetNamespace, unqualifiedPathStepPolicy) + RefQNameFactory.resolveRef(qnameString, scope, noPrefixNamespace, unqualifiedPathStepPolicy) def parseExtSyntax(extSyntax: String): (Option[String], NS, String) = { val res = @@ -168,19 +168,22 @@ object QName { def resolveStep( qnameString: String, scope: scala.xml.NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy ): Try[StepQName] = { - // TODO: We pass in NoNamespace instead of targetNamespace here, which may not be correct in - // all cases. If the step being referenced is a global element or if elementFormDefault is - // qualified then we probably do want to use targetNamespace to look it up since those - // elements likely have a namespace. But for non-qualified local steps, we probably do just - // want to use NoNamespace since the step won't have a namespace. However, this is sort of a - // chicken-and-egg problem--we need to know the namespace to how to find the step, but we - // don't know which namespace to use (NoNamespace or targetNamespace) unless we've already - // found the same. Instead, we use NoNamespace and let the flexibility that - // unqualfiedPathStepPolicy gives use help to find the step element. Possibly related to - // DAFFODIL-2917 + // It is not clear what namespace to use when a path step does not have a prefix and there + // is no default namespace defined. The step could be to a global element in the same + // schema, in which case noPrefixNamespace is probably the right choice. But if the step is + // to a local element declaration and elementFormDefault=unqualifed then no-namespace should + // be used. Or if a path step references an element in a completely different schema, then + // it depends on the namespaces declared in that schema. So we can't really say for sure + // what namespace to use. + // + // So we ignore the passed in noPrefixNamespace parameter and instead pass in NoNamespace to + // resolveRef. Resolving steps will use the unqualifiedPathStepPolicy, which will cause it + // to use either the default namespace or NoNamespace for unprefixed steps. + // + // This will likely change as part of DAFFODIL-2917. StepQNameFactory.resolveRef(qnameString, scope, NoNamespace, unqualifiedPathStepPolicy) } @@ -507,23 +510,25 @@ protected trait RefQNameFactoryBase[T] { protected def resolveDefaultNamespace( scope: scala.xml.NamespaceBinding, unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy - ): Option[String] + ): Option[NS] protected def constructor(prefix: Option[String], local: String, namespace: NS): T /** - * This variant to resolve normal QNames such as in a ref="pre:local" syntax, or - * a path step like these steps .../foo/bar:baz/quux. + * Resolve a reference to a QName. Note that the reference may or may not be prefixed. This + * function supports references to global declarations or to local declarations when resolving + * steps in DFDL path expressions. Note that step and non-step references are handled exactly + * the same except for differences in how the default namespace is used for unprefixed + * references. This difference is implemented by the resolveDefaultNamespace function. */ - def resolveRef( + final def resolveRef( qnameString: String, scope: scala.xml.NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy ): Try[T] = Try { qnameString match { case QNameRegex.QName(prefix, local) => { - // note that the prefix, if defined, can never be "" val pre = Option(prefix) val preNS = pre.map { p => @@ -531,15 +536,13 @@ protected trait RefQNameFactoryBase[T] { throw new QNameUndefinedPrefixException(p) } } - val ns = preNS match { - case None => { - // there was no prefix, use the default namespace (i.e. xmln="...") if defined. If - // not defined, use the targetNamespace - val defaultNS = resolveDefaultNamespace(scope, unqualifiedPathStepPolicy) - defaultNS.map(NS(_)).getOrElse(targetNamespace) - } - case Some(n) => n - } + // if we have a prefix, use its associated namespace. If we don't, we use the default + // namespace for this type of resolution (i.e. ref vs step). If that does not exist, + // then we use the noPrefixNamespace, which is based on targetNamespace and + // include/import + val ns = preNS + .orElse(resolveDefaultNamespace(scope, unqualifiedPathStepPolicy)) + .getOrElse(noPrefixNamespace) val res = constructor(pre, local, ns) res } @@ -553,53 +556,16 @@ object RefQNameFactory extends RefQNameFactoryBase[RefQName] { override def constructor(prefix: Option[String], local: String, namespace: NS) = RefQName(prefix, local, namespace) - override def resolveDefaultNamespace( - scope: scala.xml.NamespaceBinding, - unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy - ) = - Option(scope.getURI(null)) // could be a default namespace - /** - * Variant used to deal with extended syntax, e.g., from specifying names at the CLI - * or for variable binding mechanisms like from the command line options of Daffodil CLI which - * accept the extended syntax. + * For normal QNames, (i.e. non-expression steps), we just return the default namespace if one + * exists */ - def resolveExtendedSyntaxRef( - extSyntax: String, + override def resolveDefaultNamespace( scope: scala.xml.NamespaceBinding, - targetNamespace: NS, unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy - ): Try[RefQName] = Try { - val (pre, ns, local) = QName.parseExtSyntax(extSyntax) + ): Option[NS] = + Option(scope.getURI(null)).map(NS(_)) - // note that the prefix, if defined, can never be "" - val preNS = pre.map { p => - Option(scope.getURI(p)).map(NS(_)).getOrElse { - throw new QNameUndefinedPrefixException(p) - } - } - val resolvedNS = (preNS, ns) match { - case (None, UnspecifiedNamespace) => { - // if neither prefix nor namespace was specified, use the default namespace (i.e. - // xmln="...") if defined. If not defined, use the targetNamespace. - val defaultNS = resolveDefaultNamespace(scope, unqualifiedPathStepPolicy) - defaultNS.map(NS(_)).getOrElse(targetNamespace) - } - case (None, n) => n - case (Some(pn), UnspecifiedNamespace) => pn - case (Some(pn), n) => { - // TODO: Is this actually an invariant, or should this be an exception simlar to - // QNameUndefinedPrefixException? - Assert.invariant( - pn eq n, - "namespace from prefix and scope, and ns argument are inconsitent." - ) - n - } - } - val res = constructor(pre, local, resolvedNS) - res - } } object StepQNameFactory extends RefQNameFactoryBase[StepQName] { @@ -607,17 +573,23 @@ object StepQNameFactory extends RefQNameFactoryBase[StepQName] { override def constructor(prefix: Option[String], local: String, namespace: NS) = StepQName(prefix, local, namespace) - /* This is what needs Tunables and propagates into Expression */ + /** + * When resolving step QNames without a prefix, we use the unqualifiedPathStepPolicy to + * determine whether or not to use the default namespace if one exists. + * + * This is what needs Tunables and propagates into Expression + */ override def resolveDefaultNamespace( scope: scala.xml.NamespaceBinding, unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy - ) = { + ): Option[NS] = { unqualifiedPathStepPolicy match { - case UnqualifiedPathStepPolicy.NoNamespace => None // don't consider default namespace + case UnqualifiedPathStepPolicy.NoNamespace => + Some(NoNamespace) case UnqualifiedPathStepPolicy.DefaultNamespace => - Option(scope.getURI(null)) // could be a default namespace + Option(scope.getURI(null)).map(NS(_)) case UnqualifiedPathStepPolicy.PreferDefaultNamespace => - Option(scope.getURI(null)) // could be a default namespace + Option(scope.getURI(null)).map(NS(_)) } } } diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNames.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNames.scala index d8d30d33a0..43e119aa22 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNames.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/lib/xml/QNames.scala @@ -61,13 +61,18 @@ trait ResolvesQNames extends ThrowsSDE { def namespaces: scala.xml.NamespaceBinding def unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy - def targetNamespace: NS + def noPrefixNamespace: NS /** * If prefix of name is unmapped, SDE */ def resolveQName(qnString: String): RefQName = { - val eQN = QName.resolveRef(qnString, namespaces, targetNamespace, unqualifiedPathStepPolicy) + val eQN = QName.resolveRef( + qnString, + namespaces, + noPrefixNamespace, + unqualifiedPathStepPolicy + ) // we don't want to just throw the exception, we want to // convert to an SDE, so we use recover val res = eQN.recover { ThrowSDE }.get diff --git a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/schema/annotation/props/TestGeneratedProperties.scala b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/schema/annotation/props/TestGeneratedProperties.scala index e5e6630aeb..3448986b86 100644 --- a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/schema/annotation/props/TestGeneratedProperties.scala +++ b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/schema/annotation/props/TestGeneratedProperties.scala @@ -55,7 +55,7 @@ class TestGeneratedProperties { def lineDescription: String = ??? def locationDescription: String = ??? def namespaces: scala.xml.NamespaceBinding = ??? - def targetNamespace: NS = ??? + def noPrefixNamespace: NS = ??? def schemaFileLocation: SchemaFileLocation = ??? val xml = bagOfProps diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/BasicComponent.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/BasicComponent.scala index dcadbaa95c..a45263cc53 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/BasicComponent.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/BasicComponent.scala @@ -18,7 +18,6 @@ package org.apache.daffodil.runtime1 import org.apache.daffodil.lib.oolag.OOLAG.OOLAGHost -import org.apache.daffodil.lib.xml.ResolvesQNames import org.apache.daffodil.runtime1.dsom.ImplementsThrowsOrSavesSDE import org.apache.daffodil.runtime1.processors.HasTunable @@ -28,13 +27,9 @@ import org.apache.daffodil.runtime1.processors.HasTunable * grammar subsystem components (e.g, Combinators), etc. * * Common to them is OOLAG, and availablility of Daffodil's - * tunables, and the ability to resolve QNames + * tunables. */ -trait BasicComponent - extends OOLAGHost - with HasTunable - with ResolvesQNames - with ImplementsThrowsOrSavesSDE { +trait BasicComponent extends OOLAGHost with HasTunable with ImplementsThrowsOrSavesSDE { /** * Components have an initialize protocol. diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala index 28a0e897d9..e51462160a 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala @@ -309,7 +309,7 @@ class InteractiveDebugger( NodeInfo.Boolean, expression, context.dpathCompileInfo.namespaces, - context.dpathCompileInfo.targetNamespace, + context.dpathCompileInfo.noPrefixNamespace, context.dpathCompileInfo, false, hostForDiags, @@ -1109,7 +1109,7 @@ class InteractiveDebugger( else expression val context = state.getContext() val namespaces = context.dpathCompileInfo.namespaces - val targetNamespace = context.dpathCompileInfo.targetNamespace + val noPrefixNamespace = context.dpathCompileInfo.noPrefixNamespace val expressionWithBraces = if (!DPathUtil.isExpression(adjustedExpression)) "{ " + adjustedExpression + " }" else adjustedExpression @@ -1121,7 +1121,7 @@ class InteractiveDebugger( NodeInfo.AnyType, expressionWithBraces, namespaces, - targetNamespace, + noPrefixNamespace, context.dpathCompileInfo, isEvaluatedAbove, hostForDiags, @@ -2371,7 +2371,7 @@ class DebuggerHost(override val tunable: DaffodilTunables) */ // Members declared in org.apache.daffodil.lib.xml.ResolvesQNames def namespaces: scala.xml.NamespaceBinding = ??? - def targetNamespace: NS = ??? + def noPrefixNamespace: NS = ??? def unqualifiedPathStepPolicy: org.apache.daffodil.lib.api.UnqualifiedPathStepPolicy = ??? // Members declared in org.apache.daffodil.lib.exceptions.ThrowsSDE def schemaFileLocation: org.apache.daffodil.lib.exceptions.SchemaFileLocation = ??? diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/CompiledExpression1.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/CompiledExpression1.scala index 07f85b5d29..7db20fb569 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/CompiledExpression1.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/CompiledExpression1.scala @@ -207,7 +207,7 @@ class DPathCompileInfo( @TransientParam parentsDelay: Delay[Seq[DPathCompileInfo]], val variableMap: VariableMap, val namespaces: scala.xml.NamespaceBinding, - val targetNamespace: NS, + val noPrefixNamespace: NS, val path: String, override val schemaFileLocation: SchemaFileLocation, val unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy @@ -342,7 +342,7 @@ class DPathElementCompileInfo( // to realize the by-name arg expression. elementChildrenCompileInfoDelay: Delay[Seq[DPathElementCompileInfo]], namespaces: scala.xml.NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, path: String, val name: String, val isArray: Boolean, @@ -358,7 +358,7 @@ class DPathElementCompileInfo( parentsDelay.asInstanceOf[Delay[Seq[DPathCompileInfo]]], variableMap, namespaces, - targetNamespace, + noPrefixNamespace, path, sfl, unqualifiedPathStepPolicy diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/ExpressionCompiler.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/ExpressionCompiler.scala index b3025fc10b..b1811f1f3c 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/ExpressionCompiler.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/dsom/ExpressionCompiler.scala @@ -32,7 +32,7 @@ trait ExpressionCompilerBase[T <: AnyRef] { nodeInfoKind: NodeInfo.Kind, exprWithBracesMaybe: String, namespaces: NamespaceBinding, - targetNamespace: NS, + noPrefixNamespace: NS, compileInfoWherePropertyWasLocated: DPathCompileInfo, isEvaluatedAbove: Boolean, host: BasicComponent, diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala index b46573290d..d13b91e302 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/RuntimeData.scala @@ -96,7 +96,7 @@ sealed trait RuntimeData def variableMap: VariableMap def unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy def namespaces: NamespaceBinding - def targetNamespace: NS + def noPrefixNamespace: NS def diagnosticDebugName: String override def toString = diagnosticDebugName // diagnostic messages depend on toString doing this @@ -175,7 +175,7 @@ sealed abstract class TermRuntimeData( } final def namespaces = dpathCompileInfo.namespaces - final def targetNamespace = dpathCompileInfo.targetNamespace + final def noPrefixNamespace = dpathCompileInfo.noPrefixNamespace private val termID = TermRuntimeData.generateTermID @@ -215,7 +215,7 @@ sealed class NonTermRuntimeData( val diagnosticDebugName: String, val path: String, override val namespaces: NamespaceBinding, - override val targetNamespace: NS, + override val noPrefixNamespace: NS, val unqualifiedPathStepPolicy: UnqualifiedPathStepPolicy ) extends RuntimeData {} @@ -231,7 +231,7 @@ final class SimpleTypeRuntimeData( diagnosticDebugNameArg: String, pathArg: String, namespacesArg: NamespaceBinding, - targetNamespaceArg: NS, + noPrefixNamespaceArg: NS, val primType: NodeInfo.PrimType, val noFacetChecks: Boolean, val patternValues: Seq[FacetTypes.FacetValueR], @@ -253,7 +253,7 @@ final class SimpleTypeRuntimeData( diagnosticDebugNameArg, pathArg, namespacesArg, - targetNamespaceArg, + noPrefixNamespaceArg, unqualifiedPathStepPolicyArg ) { @@ -659,6 +659,7 @@ sealed class ElementRuntimeData( override val minimizedScope: NamespaceBinding, defaultBitOrderArg: BitOrder, val optPrimType: Option[PrimType], + val targetNamespace: NS, val optSimpleTypeRuntimeData: Option[SimpleTypeRuntimeData], val optComplexTypeModelGroupRuntimeData: Option[ModelGroupRuntimeData], val minOccurs: Long, @@ -786,7 +787,7 @@ sealed abstract class ErrorERD(local: String, namespaceURI: String) Seq[DPathElementCompileInfo]() ).force, // elementChildrenCompileInfoDelay: Delay[Seq[DPathElementCompileInfo]], null, // namespaces: scala.xml.NamespaceBinding, - null, // targetNamespace: NS, + null, // noPrefixNamespace: NS, local, // path: String, local, // val name: String, false, // val isArray: Boolean, @@ -805,6 +806,7 @@ sealed abstract class ErrorERD(local: String, namespaceURI: String) null, // minimizedScopeArg: => NamespaceBinding, null, // defaultBitOrderArg: => BitOrder, None, // optPrimTypeArg: => Option[PrimType], + null, // targetNamespaceArg: => NS, null, // optSimpleTypeRuntimeDataArg: => Option[SimpleTypeRuntimeData], null, // optComplexTypeModelGroupRuntimeDataArg: => Option[ModelGroupRuntimeData], 0L, // minOccursArg: => Long, @@ -1044,7 +1046,7 @@ final class VariableRuntimeData( diagnosticDebugNameArg: String, pathArg: String, namespacesArg: NamespaceBinding, - targetNamespaceArg: NS, + noPrefixNamespaceArg: NS, val external: Boolean, val direction: VariableDirection, maybeDefaultValueExprDelay: Delay[Maybe[CompiledExpression[AnyRef]]], @@ -1059,7 +1061,7 @@ final class VariableRuntimeData( diagnosticDebugNameArg, pathArg, namespacesArg, - targetNamespaceArg, + noPrefixNamespaceArg, unqualifiedPathStepPolicyArg ) { diff --git a/daffodil-schematron/src/test/resources/xsd/with-ns-1.dfdl.xsd b/daffodil-schematron/src/test/resources/xsd/with-ns-1.dfdl.xsd index 247f51060a..39ee6a8783 100644 --- a/daffodil-schematron/src/test/resources/xsd/with-ns-1.dfdl.xsd +++ b/daffodil-schematron/src/test/resources/xsd/with-ns-1.dfdl.xsd @@ -24,7 +24,7 @@ - + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_base.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_base.dfdl.xsd index 913eb7f365..0e21f819e3 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_base.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_base.dfdl.xsd @@ -17,13 +17,14 @@ --> + targetNamespace="http://baseSchema.com" xmlns:cs="http://stepSchema.com" xmlns:ex="http://www.example.com" + xmlns:bs="http://baseSchema.com"> - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_step.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_step.dfdl.xsd index 857de757de..47ba517a4e 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_step.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/cycle_step.dfdl.xsd @@ -17,13 +17,14 @@ --> + targetNamespace="http://stepSchema.com" xmlns:cb="http://baseSchema.com" xmlns:ex="http://www.example.com" + xmlns:ss="http://stepSchema.com"> - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat01.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat01.dfdl.xsd new file mode 100644 index 0000000000..a44fd43fd4 --- /dev/null +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat01.dfdl.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat02.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat02.dfdl.xsd new file mode 100644 index 0000000000..3cc105cb73 --- /dev/null +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat02.dfdl.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat03.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat03.dfdl.xsd new file mode 100644 index 0000000000..ca316f7536 --- /dev/null +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat03.dfdl.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat04.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat04.dfdl.xsd new file mode 100644 index 0000000000..f9523471b8 --- /dev/null +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/generalFormat04.dfdl.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/includeImport.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/includeImport.tdml index e91563ab3e..84d6acb3a2 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/includeImport.tdml +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/includeImport.tdml @@ -22,7 +22,9 @@ xmlns:gpf="http://www.ibm.com/dfdl/GeneralPurposeFormat" xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData" xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:a01="http://a01.com" xmlns:b01="http://b01.com" + xmlns:a01="http://a01.com" + xmlns:b01="http://b01.com" + xmlns:ex="http://example.com/" defaultRoundTrip="true"> @@ -85,5 +87,42 @@ /org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd + + + + + + + example + + + + + + + + + example + + + + + + + + + example + + + + + + + + defineFormat + {}GeneralFormat + not found + + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_01.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_01.dfdl.xsd index 37836414c5..d2cdd2cc11 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_01.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_01.dfdl.xsd @@ -17,13 +17,14 @@ --> + targetNamespace="http://baseSchema.com" xmlns:a01="http://a01.com" xmlns:b01="http://b01.com" + xmlns:bs="http://baseSchema.com"> - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_02.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_02.dfdl.xsd index 89146f95f0..3fd2d4a466 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_02.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_02.dfdl.xsd @@ -17,13 +17,14 @@ --> + targetNamespace="http://baseSchema.com" xmlns:a02="http://a02.com" xmlns:b02="http://b02.com" + xmlns:bs="http://baseSchema.com"> - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_04.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_04.dfdl.xsd index 88f0298e28..2b35354504 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_04.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_04.dfdl.xsd @@ -17,13 +17,14 @@ --> + targetNamespace="http://baseSchema.com" xmlns:a04="http://a04.com" xmlns:b04="http://b04.com" + xmlns:bs="http://baseSchema.com"> - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_06_valid.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_06_valid.dfdl.xsd index 6a9d1c9177..91852294c7 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_06_valid.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/multi_base_06_valid.dfdl.xsd @@ -17,13 +17,14 @@ --> + targetNamespace="http://baseSchema.com" xmlns:base="http://baseSchema.com" xmlns:b06="http://b06.com" + xmlns:bs="http://baseSchema.com"> - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/primTypesPrefixes.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/primTypesPrefixes.dfdl.xsd index ef3ac522d8..ba7c8cd0ab 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/primTypesPrefixes.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/primTypesPrefixes.dfdl.xsd @@ -28,7 +28,7 @@ We want file and line number to be of the annotation below, not the xs:schema element above. Note: don't change the line number here. The test checks it. --> - + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname1.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname1.dfdl.xsd index 98d7aba267..260adbf4b7 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname1.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname1.dfdl.xsd @@ -42,7 +42,7 @@ - + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname2.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname2.dfdl.xsd index db6ebaf59a..faaafa502e 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname2.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section06/namespaces/qname2.dfdl.xsd @@ -37,7 +37,7 @@ - + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/unordered_namespaces_03.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/unordered_namespaces_03.dfdl.xsd index 73c16e2a20..e968af6c51 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/unordered_namespaces_03.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section14/unordered_sequences/unordered_namespaces_03.dfdl.xsd @@ -16,13 +16,14 @@ limitations under the License. --> - + - + diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/first_schema.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/first_schema.dfdl.xsd index d30ff3b69b..6931192b49 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/first_schema.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/first_schema.dfdl.xsd @@ -26,7 +26,7 @@ - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/home_schema.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/home_schema.dfdl.xsd index baf65bbc02..cf9e3a11d0 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/home_schema.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/home_schema.dfdl.xsd @@ -26,7 +26,7 @@ - diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/second_schema.dfdl.xsd b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/second_schema.dfdl.xsd index 9e4b6c4d19..7f94fc76fe 100644 --- a/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/second_schema.dfdl.xsd +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section23/dfdl_functions/second_schema.dfdl.xsd @@ -23,7 +23,7 @@ - diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section06/namespaces/TestNamespaces.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section06/namespaces/TestNamespaces.scala index 045ee2992b..f91369fe7b 100644 --- a/daffodil-test/src/test/scala/org/apache/daffodil/section06/namespaces/TestNamespaces.scala +++ b/daffodil-test/src/test/scala/org/apache/daffodil/section06/namespaces/TestNamespaces.scala @@ -251,4 +251,9 @@ class TestNamespaces { @Test def test_noTargetNamespace_01(): Unit = { runner.runOneTest("noTargetNamespace_01") } @Test def test_noTargetNamespace_02(): Unit = { runner.runOneTest("noTargetNamespace_02") } + + @Test def test_generalFormat01(): Unit = { runner3.runOneTest("generalFormat01") } + @Test def test_generalFormat02(): Unit = { runner3.runOneTest("generalFormat02") } + @Test def test_generalFormat03(): Unit = { runner3.runOneTest("generalFormat03") } + @Test def test_generalFormat04(): Unit = { runner3.runOneTest("generalFormat04") } }