Skip to content

Commit a003d3c

Browse files
Clarify AXIS2-6053 diagnostic hint to indicate it is one possible cause
Reword the hint to say "if this attribute is expected to be valid, one common cause is..." rather than "This may be caused by...", making it clear the hint is advisory and only relevant when the attribute should have been allowed by the schema. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0e7464a commit a003d3c

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
8888
static String appendRefHint(SAXException ex) {
8989
String msg = ex.getMessage();
9090
if (msg != null && msg.contains("cvc-complex-type.3.2.2")) {
91-
return ". This may be caused by a schema using xs:attribute ref= to reference"
91+
return ". Note: if this attribute is expected to be valid,"
92+
+ " one common cause is a schema using xs:attribute ref= to reference"
9293
+ " an attribute from an external namespace (e.g., xmime:contentType)"
9394
+ " whose schema was not imported or could not be resolved."
94-
+ " Consider defining the attribute inline instead of using ref=,"
95-
+ " or ensure the referenced schema is accessible.";
95+
+ " In that case, ensure the referenced schema is accessible"
96+
+ " or define the attribute inline instead of using ref=.";
9697
}
9798
return "";
9899
}

modules/schema-validation/src/test/java/org/apache/axis2/validation/SchemaValidationHandlerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public void testAppendRefHintForCvcComplexType322() {
4949
SAXException ex = new SAXException(
5050
"cvc-complex-type.3.2.2: Attribute 'contentType' is not allowed to appear in element 'foo'");
5151
String hint = SchemaValidationHandler.appendRefHint(ex);
52+
assertThat(hint).contains("if this attribute is expected to be valid");
5253
assertThat(hint).contains("xs:attribute ref=");
53-
assertThat(hint).contains("xmime:contentType");
5454
assertThat(hint).contains("not imported or could not be resolved");
5555
}
5656

@@ -128,7 +128,7 @@ public void testInvokeProducesRefHintForUnexpectedAttribute() throws Exception {
128128
assertThatThrownBy(() -> handler.invoke(msgCtx))
129129
.isInstanceOf(AxisFault.class)
130130
.hasMessageContaining("cvc-complex-type.3.2.2")
131-
.hasMessageContaining("xs:attribute ref=")
132-
.hasMessageContaining("not imported or could not be resolved");
131+
.hasMessageContaining("if this attribute is expected to be valid")
132+
.hasMessageContaining("xs:attribute ref=");
133133
}
134134
}

0 commit comments

Comments
 (0)