• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating hyperlinks from XML (noob)

Contributor ,
Oct 14, 2012 Oct 14, 2012

Copy link to clipboard

Copied

Hi,

I'm researching how to do this but thought I'd back it up with a question here.

My XML has hyperlinks within it which I'd like to be active links when the InDesign doc is exported as a PDF.

The XML currently looks like:

<ArticleTitle>&lt;a href='http://www.url.com/link.htm' &gt;Text to become hyperlink&lt;/a&gt;</ArticleTitle>

When I import it as it stands, in InDesign it looks like:

<a href=’http://www.url.com/link.htm’ >Text to become hyperlink</a>

What steps should I add to my script to format this and create the appropriate hyperlinks?

The import script already has plenty of search & replace, mapping to styles and error catching so adding a bit more won't be an issue - knowing how best to do it is

Thanks very much in advance,

Simon.

TOPICS
Scripting

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 14, 2012 Oct 14, 2012

Copy link to clipboard

Copied

1. By Using evaluate xpath expression, you can get the //a[@href] elements.

2. Iterate those elements.

3. Set hyperlink text source then add hyperlink to the source text using the attribute value.

Thanks,

Green4ever

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 15, 2012 Oct 15, 2012

Copy link to clipboard

Copied

Thanks for that. This will take me a while (inexperienced scripter...)

3. Setting the hyperlink as an attribute. Below is how I imagined the XML should be structured:

<ArticleTitle href="http://www.link.com">Text to be hyperlinked</ArticleTitle>

The above doesn't create a hyperlink, which I sort of expected it to.

I tried adding the hyperlink within InDesign and exporting the XML to see how it should be formatted but the hyperlink created in InDesign doesn't appear.

In the meantime, I'll continue to learn about xpath expressions...

Thanks again,

Simon.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 18, 2012 Oct 18, 2012

Copy link to clipboard

Copied

LATEST

Okay, still stuck here. I cannot find any reference for how to include the URL in an XML tag that carries through into InDesign. Do I need to script that so it grabs the attribue for an XML element and adds the URL to a hyperlink within InDesign?

I believe I can get the XML structured so the URL is an attribute rather than a seperate XML element. Otherwise I'll cross that bridge once I crack getting the hyperlink into InDesign.

Can anyone help or point me in the right direction?

Thanks,

Simon.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines