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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Need to fetch original href (not encoded one) via APP

rr-3
7-Bedrock

Need to fetch original href (not encoded one) via APP

//APP Code in Image Tag

var href=imageNode.getAttribute("href");

This gives me encoded value.For ex X-WC//=000000651.svg will give xwc_3D8234567821.svg ,some encoded value.

So need solution to get original  href value which is present in image tag attribute in xml.

ACCEPTED SOLUTION

Accepted Solutions
rr-3
7-Bedrock
(To:rr-3)

@all

I got the solution !!

My aim was to get the windchill no which should come after every images in pdf output.

So i called ACL to fetch the windchill no in outputclass,then i wrote app in styler to publish it in pdf.

Please click on the link  To Fetch PTC Server system attributes in XML to find ACL implementation to fetch PTC server system attributes in image element

View solution in original post

11 REPLIES 11
ChrisWestern
12-Amethyst
(To:rr-3)

Hi Romesh,

Might need a little more info, getAttribute should return just a string.

Might depend on your application of it with imageNode, are you in APP or Styler?

Is this the raw returned the value of the attribute from the href var?

Your result string also hints to me possibly at a object graphic autoloaded tag name and not some escaped character substitution!?

Regards

Chris

SimonTaylor
13-Aquamarine
(To:rr-3)

Hi Romesh

Are you using APP in Styler? Or as a standalone? As Chris said, the method will return the string value present in the XML. If you're using Styler then be aware that the composition pipeline will put new attribute values for href on image tags as it will create local temporary copies of them for the publishing process.

Simon

Hi Simon,

you correctly pointed out as  I am using APP from styler and something else is  returning via APP which is encoded value of href.So is  there any way to get the actual value of href present in XML

Thanks

Romesh

Once the content has been bursted into Windchill the original image filename no longer makes sense. This is because the image itself is imported to Windchill. You can retrieve the image from Windchill using the x-wc URL in the attribute .. ?

If you absolutely needed the original image @href then you would have to save or duplicate it somehow prior to the burst process. This would probably require you to (mis)use an existing attribute or add a new one to your DTD/Schema. e.g. <image href="abc123.svg" href2="abc123.svg"> then @href2 will remain available.

Another idea would be to connect in to Windchill and see if the original filename is saved as an attribute on the image object (I suspect it might be). If it is, you can use a Windchill API call to retrieve the metadata attribute from Windchill itself. A bit more complicated than an XML attribute lookup though.

rr-3
7-Bedrock
(To:rr-3)

@all........thanks for the response

Requirement-

After every image  windchill number should come.

My approach-

When you check in the the DITA file or when you insert the image in the DITA from windchill,your image href attribute will be populated as x-wc//=0000000081.svg.

So i wrote buisness logic in APP by fetching the href and did string manipulatation.But while fetching the href attribute value via app code in stylesheet, i am not getting the actual href what i see href in image tag in xml.I am getting the encoded value of href. I tried to decode href using var uri_dec = decodeURIComponent("href");but it is not able to decode it and i am still getting encoded href value.

Now I understand. How are you retrieving the @href attribute value? There are at least 4 ways in APP I can think of, perhaps one of those methods isn't working the way you want.

1. Showstring: $^attr#
2. XPath: ^[xpath @attr]

3. Javascript code: formatting.currentXMLNode.attributes.attr.value;

4. Jf tag code: arguments[0].attributes.attr;

It would be helpful to see an example of what you are seeing in Arbortext Editor XML view versus what APP returns when you try and retrieve the attribute value. e.g. screenshot or exact text.

Hi Gareth,

  Pfa screenshot


windchill picture2.PNG

windchill picture.PNG

I used your piece of code to fetch href value but still I am getting encoded href value.

Actual Href=x-wc://=0000000482.svg

Href fetched from app code=xwc2787794878818342464.svg

Thanks

Romesh

SimonTaylor
13-Aquamarine
(To:rr-3)

Hi Romesh - if you use Gareth's methods you get the correct answer for the XML that APP is processing. As I described (or tried to) above, the XML that APP receives will not be the same as the source. When publishing from Windchill or with PE, the XML will go through the 'composition pipeline' which will change @hrefs to reflect the fact that PE will store graphics in a temporary location (as in your screenshot). When PE executes a publish request, it creates a temp folder and populates it with all the graphical content it will need. It also updates the @href values to point to these temporary files. What you're seeing is the result of that process.

I don't know of a way to get the original @href value because the link back to the source XML is not available to APP...

Simon

Exactly what Simon said! Your best bet is to add a pre-publish process that duplicates the @href values to some sort of @id attribute that will remain untouched by the Composition Pipeline. Your pre-publish script could be implemented in something like ACL, Java or XSLT. Your APP code would then pickup the @id instead of @href.

TimPhelps
12-Amethyst
(To:rr-3)

Romesh,

   Were any of these answer the "Correct Answer" or a helpful answer?

Setting the "Correct Answer", lets the community know that this thread is probably worth viewing.

rr-3
7-Bedrock
(To:rr-3)

@all

I got the solution !!

My aim was to get the windchill no which should come after every images in pdf output.

So i called ACL to fetch the windchill no in outputclass,then i wrote app in styler to publish it in pdf.

Please click on the link  To Fetch PTC Server system attributes in XML to find ACL implementation to fetch PTC server system attributes in image element

Announcements

Top Tags