cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Need a way to change attribute

ptc-3063012
1-Visitor

Need a way to change attribute

Hello adepters,

I looking for ACL help to perform attribute value change for the selected part of xml file. In my schema I have a attribute called copyfit and this attribute is available in some block level element. So when I select content of xml and activate the ACL code it should prompt the user to put any value between 0-9 and the copyfit attribute value should be changed/inserted as per the user input.

For example if my selected content is

<section>

<head></head>

<para><para>

<list></list>

</section>

the attribute copyfit is only available for <section> and <head> then it should only change/insert in those elements only.

Thanks in advance.

Karthik

5 REPLIES 5

Karthik,

I attached an acl file that is similar to what you asked and might do what you want. I think Lynn Hales posted it to adepters several years ago. It works to delete or change attributes. As long as you enter the attribute name I don't think it cares what the element name is. Just source it on the command line.

You might be able to adapt it to your exact need, but I don't know how. I wish there were more little scripts that do something general and useful like this one posted for guys like me that cannot write acl.

Hope it helps you,
-Andy
\ / Andy Esslinger LM Aero - Tech Order Data
_____-/\-_____ (817) 279-0442 1 Lockheed Blvd, Mail Zone 4285
\_\/_/ (817) 777 3047 Fort Worth, TX 76108

I think the mail server blocked the attachment. Let's see if it can be pasted inline:

#################### START ####################

package attr_mods
function mod_start(){};
function attr_chg(){};
function attr_del(){}
function mod_start() {;
eval('window_destroy("msgwin1")');
caret first,first;
set tabletags=on;
start=response("Do you wish to delete/remove specific attributes or change attribute values?\
\
","Delete","Change","Cancel")
if(start=='1')
{
attr_mods::attr_del();
}
if(start=='2')
{
attr_mods::attr_chg();
}
if(start=='3')
{
return 0
}
}
function attr_del() {
readvar -prompt "Enter the tag name you wish to change the attribue on." elname \
-prompt "Enter attribute name you wish to change." attname; #\
#-prompt "Enter the new attribute value." attvalue;
o=oid_first();
while (oid_valid(o))
{
if($elname==" ")
{elname=$main::tagname}
tag=tag_has_attr($elname,"label");
# eval"tag is equal to $tag"output=>*
if(oid_has_attr(o,"$attname")=="1")
{
tag=0
eval"The $attname attribute in $elname $main::tagname has been deleted."output=>*;
oid_delete_attr(o,$attname)
}
o=oid_forward(o);
goto_oid(o)
}
}


function attr_chg() {
readvar -prompt "Enter the tag name you wish to change the attribue on." elname \
-prompt "Enter attribute name you wish to change." attname \
-prompt "Enter the new attribute value." attvalue;
o=oid_first();
while (oid_valid(o))
{
if($elname==" ")
{elname=$main::tagname}
tag=tag_has_attr($elname,"label");
# eval"tag is equal to $tag"output=>*
if($tagname==$elname)
{
tag=0
eval"The $attname attribute in $elname $main::tagname has been changed to $attvalue."output=>*;
oid_modify_attr(o,$attname,$attvalue)
}
o=oid_forward(o);
goto_oid(o)
}
}
attr_mods::mod_start()
#################### END ####################
-Andy

\ / Andy Esslinger LM Aero - Tech Order Data
_____-/\-_____ (817) 279-0442 1 Lockheed Blvd, Mail Zone 4285
\_\/_/ (817) 777 3047 Fort Worth, TX 76108


Thanks for the code Andy. That gives me a good start.

I executed the code in the command line and it seems the delete part works but the code did not not work for changing the attribute. I browsing through the ACL documentation to find ways of changing the code to the below need.

1. User selection needs to be marked.

2. Prompt the user for old attribute value and new attribute value

3. On the marked selection replace the old attribute value with the new one.

At this point we have AT processing instruction to drive the presentation output which the team don't like. So we made changed to the schema to have a attribute in every element. Now the user is not happy because he/she had to modify attribute in all elements for the required section. Only by scripting I can make this work effectively - both the parties will be happy.

Karthik

Karthik,

As Andy said, I wrote that scrip some six years ago and I haven't really done anything with it since then. I am sure some of the code does need some work.

If I get a chance tomorrow, I'll run it to see what is or is not working in the current version of Epic and try to make some changes.

I will admit that I was a relative novice ACL writter then (shoot, I still am), but it worked for what I wanted it to do at the time (and I guess that is what counts).

Lynn


---- Karthik Kumar <karthik.kumar@merrillcorp.com> wrote:
> Thanks for the code Andy. That gives me a good start.
> I executed the code in the command line and it seems the delete part works but the code did not not work for changing the attribute. I browsing through the ACL documentation to find ways of changing the code to the below need.
> 1. User selection needs to be marked.
> 2. Prompt the user for old attribute value and new attribute value
> 3. On the marked selection replace the old attribute value with the new one.
> At this point we have AT processing instruction to drive the presentation output which the team don't like. So we made changed to the schema to have a attribute in every element. Now the user is not happy because he/she had to modify attribute in all elements for the required section. Only by scripting I can make this work effectively - both the parties will be happy.
> Karthik
>
>      
> ----------     

Karthik,

I ran the script this morning and it did work for me. Now one thing with this particular script. If you need to have the values be incremented, it will not do that. It will just change the value for "X" to "Y". Though it would not be all that difficult to add a counter into the change (and to give the author a choice of incrementing the value).

I do have an even older script (wrote it in 2000) that would go through and change ID values. This one would change the first several characters of the ID. So if you need something like that, I'd be happy to send it to you.

I don't see a need to select the object when I do an 'oid_modify_attr'. When you match the element name, the oid_modify_attr() will modify the attribute in the current element with an attribute that is named in the function.

If you'd like to take this more off line to discuss any problems you're having, feel free to contact me.

Lynn

---- Lynn Hales <-> wrote:
> Karthik,
>
> As Andy said, I wrote that scrip some six years ago and I haven't really done anything with it since then. I am sure some of the code does need some work.
>
> If I get a chance tomorrow, I'll run it to see what is or is not working in the current version of Epic and try to make some changes.
>
> I will admit that I was a relative novice ACL writter then (shoot, I still am), but it worked for what I wanted it to do at the time (and I guess that is what counts).
>
> Lynn
>
>
> ---- Karthik Kumar <karthik.kumar@merrillcorp.com> wrote:
> > Thanks for the code Andy. That gives me a good start.
> > I executed the code in the command line and it seems the delete part works but the code did not not work for changing the attribute. I browsing through the ACL documentation to find ways of changing the code to the below need.
> > 1. User selection needs to be marked.
> > 2. Prompt the user for old attribute value and new attribute value
> > 3. On the marked selection replace the old attribute value with the new one.
> > At this point we have AT processing instruction to drive the presentation output which the team don't like. So we made changed to the schema to have a attribute in every element. Now the user is not happy because he/she had to modify attribute in all elements for the required section. Only by scripting I can make this work effectively - both the parties will be happy.
> > Karthik
> >
> >
>
Announcements

Top Tags