Skip to main content
1-Visitor
July 6, 2015
Solved

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

  • July 6, 2015
  • 5 replies
  • 3447 views

//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.

    Best answer by 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

    5 replies

    12-Amethyst
    July 6, 2015

    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

    14-Alexandrite
    July 6, 2015

    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

    rr-31-VisitorAuthor
    1-Visitor
    July 7, 2015

    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

    16-Pearl
    July 6, 2015

    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-31-VisitorAuthor
    1-Visitor
    July 6, 2015

    @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.

    16-Pearl
    July 6, 2015

    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.

    rr-31-VisitorAuthor
    1-Visitor
    July 7, 2015

    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

    rr-31-VisitorAuthorAnswer
    1-Visitor
    July 13, 2015

    @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