Lemme give a shot with explanin Scrutinizer code :
{
for(i=1; i<=NF; i++) { # for all fields in the line separated by field separator (in this case default FS space)
if($i~/^name="WorkJobNumber"/) # if field matches desired string
w=1 # create a variable w with value 1
if($i~/^value=/ && w) { # if field in the line matches '^value=' and w is defined (regular expression '^name="WorkJobNumber"' has been matched in the same line)
sub(/".*"/,"\"\"",$i) # substitute, in this case truncate, ..value.. with nothing.
w=0 # reset w for next line of input
}
}
}
1 # print everything
NF determines the number of fields per line.
Using that information, we can use i in a for loop with $ to evaluate each field string wise with our conditions. (NF is 4, so i is from 1 to 4, $1 being first field etc.)
awk considers record separator(RS) a line (if not stated otherwise).
So we introduce a w variable to process our conditions per line.
Everything is printed (again per line, if matched print changed if not print as is) as file is processed line by line.
Perhaps this can be improved by only checking the word after the "WorkJobNumber".
That means w is reset unconditionally, its query must happen before, and its setting must happen after.