问题
I have a dxl script that works when run in the DOORS application but does not work when it's run in batch mode. I am not sure why this would be. When running in batch mode I get the following error:
doors: assertion failed, line 3173, document.cpp: !nls_("unexpected: tree root does not have a name attribute") stack
I know that creating a GUI and things like that might cause this error but I am not doing that. The odd thing is that the script stops running in different modules and different parts in the modules. So the script breaks down in different areas of DOORS everytime run.
Here is what I think is the relevant code that might be causing the error in batch mode:
Buffer bsz = create
void addNewLineSeparator(Buffer& b)
{
if (length(b) > 0)
{
b += "\n"
}
}
void display(string s)
{
addNewLineSeparator(bsz)
bsz += s
}
void displayRich(string s)
{
addNewLineSeparator(bsz)
bsz += s
}
void displayRichWithColour(string s)
{
addNewLineSeparator(bsz)
bsz += s
}
void displayRichWithColor(string s)
{
addNewLineSeparator(bsz)
bsz += s
}
void display(Attr__ a)
{
string s = richText a
if (!null s)
{
displayRich s
}
}
string showOut(Object o, int depth) {
Link l
LinkRef lr
ModName_ otherMod = null
Module linkMod = null
ModuleVersion otherVersion = null
Object othero
string disp = null
string s = null
string plain, plainDisp
int plainTextLen
int count
bool doneOne = false
string linkModName = "*"
for l in all(o->linkModName) do {
otherVersion = targetVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) continue
othero = target l
if (null othero) {
load(otherVersion, false)
}
othero = target l
if (null othero) continue
if (isDeleted othero) continue
doneOne = true
if (depth == 1) {
s = fullName(otherMod)
if (isBaseline(otherVersion)) {
s = s " [" versionString(otherVersion) "]"
}
if (s == "")
displayRich("\\pard " " ")
else
displayRich("\\pard " s)
}
}
return s
}
for o in m do
{
print showOut(o, 1)
}
回答1:
This can happen with anything that might be reliant on a view. Batch mode for DOORS can be finicky. Also, DOORS is not exactly careful about memory management- if you can, it might make more sense to have your code split into sections, one of which runs a lightweight set that runs other code inside of an 'eval_' function. That will help keep memory de-allocation running more smoothly (a trick I used to do a full link inventory of our database- over 16000 modules opened and closed!)
To respond to your edit:
The code you are showing is Layout DXL, which is evaluated when a view is displayed- specifically, the 'displayRich' function is trying to take a richtext string and put it into the appropriate column- but that column doesn't exist, as the view context is not created in batch mode.
A simple fix would be to wrap your entire code in:
if(!isBatch){
// Your Code Here
}
This will ensure that the DXL is only calculated if the user is running DOORS in non-batch mode.
来源:https://stackoverflow.com/questions/56229908/what-are-some-common-reasons-for-why-a-dxl-script-would-work-in-doors-but-not-wh