From 8050117ff8bda2176a4cf942240f1df4b60b5aa8 Mon Sep 17 00:00:00 2001 From: Juri Leino Date: Tue, 28 Apr 2026 08:44:58 +0200 Subject: [PATCH] [fix] raise expected error in constructor The XQTS contains tests that expect illegal QNames in element and attribute constructors to raise error XPTY0004 instead of XQDY0074 --- .../java/org/exist/xquery/DynamicAttributeConstructor.java | 7 ++++--- .../src/main/java/org/exist/xquery/ElementConstructor.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/exist-core/src/main/java/org/exist/xquery/DynamicAttributeConstructor.java b/exist-core/src/main/java/org/exist/xquery/DynamicAttributeConstructor.java index 8bfc1bb919e..d13e0244a5d 100644 --- a/exist-core/src/main/java/org/exist/xquery/DynamicAttributeConstructor.java +++ b/exist-core/src/main/java/org/exist/xquery/DynamicAttributeConstructor.java @@ -112,9 +112,10 @@ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathExc throw new XPathException(this, ErrorCodes.XQDY0074, "'" + nameSeq.getStringValue() + "' is not a valid attribute name"); } - //Not in the specs but... makes sense - if(!XMLNames.isName(qn.getLocalPart())) - {throw new XPathException(this, ErrorCodes.XQDY0074, "'" + qn.getLocalPart() + "' is not a valid attribute name");} + // Catch illegal QNames + if (!XMLNames.isName(qn.getLocalPart())) { + throw new XPathException(this, ErrorCodes.XPTY0004, "'" + qn.getLocalPart() + "' is not a valid attribute name"); + } if ("xmlns".equals(qn.getLocalPart()) && qn.getNamespaceURI().isEmpty()) {throw new XPathException(this, ErrorCodes.XQDY0044, "'" + qn.getLocalPart() + "' is not a valid attribute name");} diff --git a/exist-core/src/main/java/org/exist/xquery/ElementConstructor.java b/exist-core/src/main/java/org/exist/xquery/ElementConstructor.java index 7b95fc1d655..fbb8d2d8ee9 100644 --- a/exist-core/src/main/java/org/exist/xquery/ElementConstructor.java +++ b/exist-core/src/main/java/org/exist/xquery/ElementConstructor.java @@ -304,9 +304,9 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr } } - //Not in the specs but... makes sense + // Catch Illegal QNames if (!XMLNames.isName(qn.getLocalPart())) { - throw new XPathException(this, ErrorCodes.XQDY0074, "'" + qnitem.getStringValue() + "' is not a valid element name"); + throw new XPathException(this, ErrorCodes.XPTY0004, "'" + qnitem.getStringValue() + "' is not a valid element name"); } // add namespace declaration nodes