IBM DOORS DXL脚本导出HTML报错,请求排查脚本问题
IBM DOORS DXL脚本导出HTML报错排查与修正
错误分析
针对你遇到的三个报错,逐一解析问题根源:
- Line14:export函数参数错误
你拼接导出文件名时缺少DXL必需的字符串连接符+,导致fileName变量语法无效,进而影响export函数的参数合法性。 - Line20:类型比较错误
type(item)返回的是ItemType枚举类型,不能直接与字符串"Folder"做相等比较,DXL预定义了folderType常量用于判断文件夹类型。 - Line26:文件夹查找类型不匹配
find()函数返回的是Item类型对象,无法直接赋值给Folder变量,应使用findFolder()函数直接获取Folder类型的对象。
修正后的DXL脚本
// Define the filePath to save HTML files string filePath = "C:\\Users\\t22283srv\\Desktop\\DOORS_EXPORT" // Recursive function to process folder and its subfolders void processFolder(Folder folder) { Item item for item in folder do { if (isModule(item)) { string itemPath = fullName(item) Module mod = read(itemPath) // Check if the "Object Text" attribute exists in the module if (null != find(mod, "Object Text")) { string modName = name(mod) // 使用+连接字符串,修正语法错误 string fileName = filePath + "\\" + modName + ".html" // Export the module to an HTML file string options = "-html" export(mod, fileName, options, "", "", "", "") close(mod) } else { print "模块 " fullName(item) " 缺少'Object Text'属性,已跳过导出。\n" close(mod) } } // 使用预定义常量判断文件夹类型 if (type(item) == folderType) { // 直接将Item转换为Folder类型 Folder subFolder = item processFolder(subFolder) } } } // 使用findFolder直接获取Folder对象 Folder mainFolder = findFolder("/TEST/ayberk_dxl") // 检查目标文件夹是否存在 if (null mainFolder) { print "未找到目标文件夹 /TEST/ayberk_dxl!\n" } else { // 执行导出逻辑 processFolder(mainFolder) print "导出完成。\n" }
额外注意事项
- 确保导出路径
C:\\Users\\t22283srv\\Desktop\\DOORS_EXPORT已手动创建,DXL不会自动生成目录,目录不存在会导致导出失败。 - 脚本添加了缺失属性的提示,方便排查未导出的模块。
- 导出大型模块时,可在DOORS设置中延长脚本执行超时时间,避免中断。
内容的提问来源于stack exchange,提问作者root_roxox
相关产品推荐
相关产品推荐

