项目地址:activiti-workflow
在给用户节点扩展增加抄送人的标签,通过bpmn文件导入流程报org.xml.sax.SAXParseException: 已经为元素 “userTask” 指定绑定到名称空间 “http://activiti.org/bpmn” 的属性 "XXXX。"
通过bebuggerf发现具体报错出现在XMLNSDocumentScannerImpl类
if (length > 1) {
//对元素进行校验name不为空说明有重复元素
QName name = fAttributes.checkDuplicatesNS();
if (name != null) {
if (name.uri != null) {
fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
"AttributeNSNotUnique",
new Object[]{
fElementQName.rawname, name.localpart, name.uri},
XMLErrorReporter.SEVERITY_FATAL_ERROR);
} else {
fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
"AttributeNotUnique",
new Object[]{
fElementQName.rawname, name.rawname},
XMLErrorReporter.SEVERITY_FATAL_ERROR);
}
}
}
在看checkDuplicatesNS方法
public QName checkDuplicatesNS() {
// If the list is small check for duplicates using pairwise comparison.
final int length = fLength;
if (length <= SIZE_LIMIT) {
final Attribute[] attributes = fAttributes;
for (int i = 0; i < length - 1; ++i) {
Attribute att1 = attributes[i];
for (int j = i + 1; j < length; ++j) {
Attribute att2 = attributes[j];
//只有当标签名称和命名空间一样时有返回
if (att1.name.localpart == att2.name.localpart &&
att1.name.uri == att2.name.uri) {
return att2.name;
}
}
}
return null;
}
// If the list is large check duplicates using a hash table.
else {
return checkManyDuplicatesNS();
}
}
贴上报错的对象信息

按理说不会存在两个一样的标签,莫非时重复设置,仔细检查代码后,并没有发现重复设置的地方。
自己扩展的代码,只有在CustomUserTaskXMLConverter一处设置的这个属性
@Override
@SuppressWarnings("unchecked")
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLS

在activiti项目中扩展BPMN用户任务标签时遇到解析错误,报已指定到名称空间 http://activiti.org/bpmn 的属性。经过代码审查和调试,发现错误源于activiti源码中的属性重复设置。问题定位到activiti的XML转换器,特别是CustomUserTaskXMLConverter类中。解决方法是调整BpmnXMLUtil.addCustomAttributes的isBlacklisted逻辑,避免属性冲突。
1776

被折叠的 条评论
为什么被折叠?



