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