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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Retrieve tag value and assigning to a variable (APP)

rboneti
1-Newbie

Retrieve tag value and assigning to a variable (APP)

Hi Everybody!

There is any way to I retrieve the tag's value and assigning it to a variable? Actually, I've a xpath tag and I need to get its value.

The tag is this:

<_gte:XPathString expr='_acl:eval(\"$ENV[&#x27;Test&#x27;]\")'>&lt;/_gte:XPathString>

1 ACCEPTED SOLUTION

Accepted Solutions

What you need to consider is "where" the variable information is to be stored. This may also be referred to as the variable scope.

1. Global - across entire application.

2. Document - specific to current document.

3. Format - specific to current formatting pass.

4. Page - specific to current page.

5. Element - specific to current tag.

Your #1 is Global-scope, your #2 is Element-scope and your #3 is also Global-scope and indeed scoped at the o/s process level too. APP provides "counters" which are Format-scope and they tend to be used for what I think you are attempting.

You will also find the Global-scope Javascript variables also act as Format-scope when they are used inside formatting tags. However this behaviour is only for scalar variables, not for objects or arrays.

View solution in original post

3 REPLIES 3

This looks like Source Edit of an APP Stylersheet. Is that correct? If so, you don't "save" a tag's output anywhere. It is written to the page.

As I mentioned in the other thread, this doesn't look like the normal way to do things. If you can explain what you are trying to achieve there is probably a better way to do it.

Thank you Gareth!

I thought it was not possible either.

In fact, I need to pass a value from one element to other, using APP, because it value needs to be retrieve in OnExit function. To pass this value, I've found and tested 3 ways:

1 - I created a external js file, and use get/set functions to do a global variable.

2 - I used the formatting.evaluateXPath( 'x3b2:set-userdata( "_temp_hasbefore_", "1" )' );

3 - I used the acl ENV like this: formatting.evaluateXPath( '_acl:eval( "$ENV(\"some_text\")=\"some value\"" )' );

All of these can keep a information and be retrieved in another element. But in my case, I have to do this in the following struct:

<figure>

<table>

</table>

</figure>

I've set the value in the table and gotten it in OnExit of figure.

When I use the third option to keep the informations, it only works well if I retrieve by tags.

It works:

<_gte:XPathString expr='_acl:eval(\"$ENV[&#x27;Test&#x27;]\")'>&lt;/_gte:XPathString>

It doesn't:

formatting.evaluateXPath( '_acl:eval( "$ENV(\"some_text\")" )' );

What you need to consider is "where" the variable information is to be stored. This may also be referred to as the variable scope.

1. Global - across entire application.

2. Document - specific to current document.

3. Format - specific to current formatting pass.

4. Page - specific to current page.

5. Element - specific to current tag.

Your #1 is Global-scope, your #2 is Element-scope and your #3 is also Global-scope and indeed scoped at the o/s process level too. APP provides "counters" which are Format-scope and they tend to be used for what I think you are attempting.

You will also find the Global-scope Javascript variables also act as Format-scope when they are used inside formatting tags. However this behaviour is only for scalar variables, not for objects or arrays.

Top Tags