![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Extract Section Number from Object Number? Topic Summary: E.g. 5.15.7.0-14 --> 5.15.7 Created On: 5-Dec-2007 17:02 Status: Post and Reply |
Linear : Threading : Single : Branch |
|
![]() |
![]()
|
![]() |
|
Hi All,
I've been experimenting with Regexp to try and do this, also checked in the DXL forums but I've hit a brick wall. ![]() As part of a traceability table I basically I want to have a Section Number DXL Attribute that's dynamically generated from the "Object Number" attribute. e.g. (Input) (Output) 1.1 1.1 3.4.6 3.4.6 7.1.11.0-12 7.1.11 5.6.0-16 5.6 I know Regular Expressions, I'm after something like ([0-9]+\.)+(\.*[0-9]+-[0-9]+)? Eg first set of brackets is what I want, then strip off an optional .0-16 or whatever. I'm struggling with the stuff to do with buffers and extracting? Any help appreciated! Robert Longworth |
|
![]() |
|
![]() |
|
I think I found the attached code somewhere here in the forum, but I don't know exactly where; so whoever the original author is, I apologize for not giving proper credits ...
Cheers, Peter Update: Corrections to the attached code as proposed by Louie Edited: 6-Dec-2007 at 08:32 by Peter Albert |
|
![]() |
|
![]() |
|
To Robbie: I don't mean to be a twit, but the Object Number is not actually an 'attribute', even if it has some properties like one. You retrieve it this way:
string ParaNum = number(obj). The reason its not an attribute is that its value can change without making any changes to the object; for example if you move this object or perhaps move some other object in the hierarchy above this one. Likewise, the 'Object Identifier' (identifier(obj)) and 'Level' (level(obj)) are not attributes. To Peter: [1] I don't think you can use 'tempStringOf' to permanantly assign the value to a variable. Try using your function, print the results, then do some random string and buffer manipulation, and see if the variable value 'inexplicabely' changes. [2] Also, instead of setting the bNum to the new string value, I THINK you can simply set the length of the buffer shorter, perhaps: length(bNum, startIndex-1). Not that it matters for these tiny strings. [3] appending an empty string to (number obj) will, I believe generate a duplicate reference in the string table and thus waste space. Since the 'number' function is defined as string, all you need is: bNum = number(obj). - Louie |
|
![]() |
|
![]() |
|
Louie,
thanks for the comments, you are absolutely right with each point. Especially the tempStringOf is an issue; I actually changed that without testing yesterday when I copied the code to the forum. Which was a bad idea, as it absolutely screws up the result ... It is corrected now in the script. Regards, Peter |
|
![]() |
|
![]() |
|
Another example, with regexp.
This one also matches texts that are headings' brothers, and text objects before first heading. (0-1 => 0, 3.4.5-2 =>3.4.5) Edited: 6-Dec-2007 at 10:06 by Eric Piallat |
|
![]() |
|
![]() |
|
Cheers Guys,
Extremely slick, that's just what I was after! Can anyone tell me what the "//" means in the regexp, it was confusing me yesterday, I thought // mean a literal /. i.e. delimit. I take it it's some DXL flavour of regexp syntax? Cheers! Robert Longworth |
|
![]() |
|
![]() |
|
Did you mean "\\" ?
"/", from the perl syntax, is not used in dxl. Back-slash leads to odd syntaxes, cause it serves two purposes: * Starting escape sequences in dxl strings * Escaping special chars in Regexp syntax Thus: . means any char in a regexp. \. means the dot char. (escaped dot) Corresponding syntax is: regexp "\\." regexp "\." will fail, because "\." has no meaning as a string. regexp "\\\\." will match a single \ char followed by any char. regexp "\\\\\\." will match \. ![]() regexp "\n" regexp "\\n" regexp "\\\n" Ffirst string contains <CR>, second one \n, third one \<CR>. Same meaning for regexp: match a single <CR> ![]() Edited: 6-Dec-2007 at 16:37 by Eric Piallat |
|
![]() |
|
![]() |
|
I am having trouble getting this to work. We are using 7.1, does that make a difference?
I have tried plugging the script tinto a layout dxl column and tried making a dxl attribute with no success. Am I missing something obvious? Rob Kohl |
|
![]() |
|
![]() |
|
Both scripts work fine for me in layout DXL using DOORS 7.0. Both routines return a string variable, therefore you have to add the following line to your layout DXL in order to see the result:
display sectionNumber obj Regards, Peter |
|
![]() |
|
![]() |
|
None of the script listed here return correct section number in three special cases.
Case 1 Object is a table cell Case 2 Object is table header shown in view table is deselected Case 3 Heading is created below an Object Text Object. While this is not a normal construct the script should still return the actual section number. DOORS permits this construct therefore it should be considered. (Note. this case also leads to a series of wrong values given the script previously posted on this thread.) Case 4. Some of thie scripts return incorrect section number when object is before the first section. To be considered a correct scripts should account for all the cases not just the normal cases. Edited: 18-Dec-2007 at 19:41 by ron lewis |
|
![]() |
|
![]() |
|
Yes, I believe the scripts should find the LAST ".0-" and strip that off, instead of finding the FIRST one.
BUT WAIT!!! I think the script should recursively strip off the last ".0-" if its that last 'field' in the paragraph number. That is, this works: 3.2.0-3.0-4.3, there should be no stripping since that's a heading object. Golly, that will waste a lot of string table space. Forget that. Use the attached function that determines, accurately, if a given object is in fact a 'Heading' object as far as DOORS is conserned. Use that function recursively, starting from the object and checking its parents, stopping when you find the nearest heading (which may be the original object). Handle the case where there are zero ancestor headings, which can happen. EDIT: then take that object's paragraph number. - Louie Edited: 19-Dec-2007 at 00:52 by Louie Landale |
|
![]() |
|
![]() |
|
Why all this string crunching? Doors is rubbish at that.
Here's my very simple solution that displays the section number of an object by finding it's nearest parent heading. Objects that have a Heading are heading objects, unless they are table/cells. Text objects at the top level in the hierarchy are in section zero. ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Tony:
It may be considered a bug in DOORS but your script fails to return expected values on a table object and object text that is at level 1 when the object fall after a section for example section 8. Of course this is all dependent upon a judgement call. Should a table or object text that is at level 1 but comes after section 8 but before section 9 be consider contained in section 8 or should it be consider a section 0 even though the objects have a number 8. something. This same paradox seems to exists for Louis and the other scripts contained within this thread. Edited: 19-Dec-2007 at 15:35 by ron lewis |
|
![]() |
|
![]() |
|
"Objects with Heading Text are Headings". Not quite true. When you create a new object its considered a 'heading object' as evidenced that you can see its paragraph number in the MAIN column.
An object is considered a 'Heading Object' by DOORS whenever it [1] Table Cells are never Headings [2] has Heading Text, even invisible rich-text markup [3] Has no Picture and also has no Object Text (again including invisible rich-text markup). - Louie |
|
![]() |
|
![]() |
|
Yes, I believe the scripts should find the LAST ".0-" and strip that off, instead of finding the FIRST one. Hi Louie, I have to disagree with that, at least from my users' point of view: Many of them missed the whole "hierarchy stuff", and considers that "if its displayed right into MS-Word, everything is right." And if fact, we have text objects which are childs of other text objects within the same section. (multi-object requirements, table's caption...) From that point of view, the "right" section number is the first "well-numbered" heading number met before the object in DOORS' standard view. Thus, 1.0-2.0-1.0-1 gives 1, as it's a text or a table cell after chapter 1 4-3 gives 4 as it's a text after chapter 4 1.0-2.0-1.1 shall not occur, because even my MS-loving users see there is something wrong there. (and it's OK if it returns "1", as most of the time thus objects are in fact figure's captions) |
|
![]() |
|
![]() |
|
None of the script listed here return correct section number in three special cases. Case 1 Object is a table cell Case 2 Object is table header shown in view table is deselected Case 3 Heading is created below an Object Text Object. While this is not a normal construct the script should still return the actual section number. DOORS permits this construct therefore it should be considered. (Note. this case also leads to a series of wrong values given the script previously posted on this thread.) Case 4. Some of thie scripts return incorrect section number when object is before the first section. To be considered a correct scripts should account for all the cases not just the normal cases. Hi Ron, May you clarify ? I tested my script against your four cases and haven't seen anything wrong. In fact, I've found another tricky case: Case 5: Object is child of a text object at the same level as the section heading, e.g. 1-1.0-1 It's now corrected in my first example, removing the "else" word: |
|
![]() |
|
![]() |
|
If all DOORS users were properly trained, everyone followed sensible guidlines and structured their modules "correctly" and never nested text objects, never had empty objects, always use tables sensibly and never screwed anything up ... DOORS administration and DXL coding would be a lot less fun :-)
------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Eric, attached is a pdf that shows two snapshots of a module that shows several conditions where your script failed to return expected results.
Where your script (Last Post ) failed I put word failure somewhere in the object. Text is listed as either text or failure Headings are listed as headings Header text is a cell that has object heading text used. Edited: 20-Dec-2007 at 15:32 by ron lewis |
|
![]() |
|
![]() |
|
Hi All
There seems to be two needs here. One is to provide the nearest "well-formed" heading number, and the other to include DOORS's "complex" heading numbers below text objects (1.1.0-1.1 etc). The attached code covers either case, I think. Use sectionNumber() for the former, and sectionNumberCmpx() for the latter. Although this is pretty succinct and runs (I found) faster than Eric's original regexp implementation on which it's based, I can't help thinking that Tony's no-string-processing approach is going to be MUCH faster. I just can't quite see how to do it yet... ![]() Go on Ron, test it to destruction! ![]() ------------------------- Simon Morrish simon.morrish@eu.panasonic.com http://panasonic.co.uk Panasonic ideas for life Edited: 20-Dec-2007 at 17:20 by Simon Morrish |
|
![]() |
|
![]() |
|
Simon you did make some improvements.
Attached is a pdf that shows were your two subroutine failed. Note: sectionNumber failed each place that Erics failed and sectionNumberCmpx made some improvements but failed in several cases. Always glad to provide my testing services. |
|
![]() |
|
Telelogic DOORS
» DXL Exchange
»
Extract Section Number from Object Number?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.