Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: replacing '&'
Topic Summary:
Created On: 15-Jul-2005 08:28
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Paul Tiplady, on Friday, July 15, 2005 8:42 AM

Answer:
The search for & will find the & in &amp, and replace it with &ampamp, then with &ampampamp...

You need to move the start point for your search to just after where you found the last &.

I was going to attach a code snippet, but I don't know what it needs to be - still you've got the theory now...
 15-Jul-2005 08:28
User is offline View Users Profile Print this message


Ben Herfurth

Posts: 37
Joined: 9-Jun-2005

Hello,

I have a little problem. I am parsing some text for exporting to DocBook. In the text, there might also be source code included, which has some '&' in it. So now in DocBook you must replace those with "&" as some of you might know.

I attached my code beneath, so you can see what i have tried so far. When i add the searchfunction for the '&' the script runs endlessly ...
Without the '&' while, it works perfectly ...

Thanks in advance

Ben
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 08:34
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Answer Answer
The search for & will find the & in &amp, and replace it with &ampamp, then with &ampampamp...

You need to move the start point for your search to just after where you found the last &.

I was going to attach a code snippet, but I don't know what it needs to be - still you've got the theory now...

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive

Edited: 15-Jul-2005 at 08:42 by Paul Tiplady
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 08:42
User is offline View Users Profile Print this message


Ben Herfurth

Posts: 37
Joined: 9-Jun-2005

arf, you are so right ... i didnt think of that ... thanks for your help

Ah i see the problem now, too ... The offset parametre isnt the offset from where he searches the string ...

Maybe i can try text[index:end] ....


Edited: 15-Jul-2005 at 08:46 by Ben Herfurth
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 08:43
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

Ooh! Another thought. You could replace & with !amp;, then replace !amp; with &. That would also get around the problem.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 08:47
User is offline View Users Profile Print this message


Ben Herfurth

Posts: 37
Joined: 9-Jun-2005

hm i think that would be easier then setting the offset new in every run ...
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 11:50
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

Ben, the following funtion did the job for me. There is some extra stuff in this function that you may not need so you might want to strip these bits out.

-------------------------
Tony Goodman
http://www.smartdxl.com

Edited: 15-Jul-2005 at 11:52 by Tony Goodman
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 11:56
User is offline View Users Profile Print this message


Ben Herfurth

Posts: 37
Joined: 9-Jun-2005

hey that's quite a nicething
i didn't think of writing a own funtion, cause there were already function which should do the same for me
i will try yours.
Thanks
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 12:03
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

You may find this function of use. This takes a rich text parameter and returns docbook text.
It distinguishes between requirements and other information using paragraph roles.

docbooktext.inc
docbooktext.inc  (2 KB)



-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 12:18
User is offline View Users Profile Print this message


Ben Herfurth

Posts: 37
Joined: 9-Jun-2005

that function really works fine. i added another option which you'll see below

but that one won't kill the control characters
maybe because they appear as a square (unknown character) in Doors, but when i open it with my VI they appear as a ^Y and a ^S
do you have any idea how that could work?
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 12:25
User is offline View Users Profile Print this message


Tony Goodman

Posts: 1098
Joined: 12-Sep-2002

I had a lot of trouble with special characters when writing this.
Could you test for the ascii value and then reject the character if it is not within some defined ranges?

In other words test for ALL the chracters that you WANT and reject everything else.

-------------------------
Tony Goodman
http://www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 15-Jul-2005 12:36
User is offline View Users Profile Print this message


Ben Herfurth

Posts: 37
Joined: 9-Jun-2005

hmm yes would be the only possibilty then narf ... dealing with special chars is really a big thing. And you'll never find all of them

edit: ok a comparison with "intOf(oldStr) == 19" or

char char19 = charOf(19)

oldStr == char19

doesn't work either

Edited: 15-Jul-2005 at 12:53 by Ben Herfurth
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.