Skip to main content
Bumped by Community user
Bumped by Community user
https://chat.stackexchange.com/transcript/message/44664013#44664013
Source Link
Welz
  • 10k
  • 10
  • 48
  • 83

I have xml in the following format:

   <WebsiteAsHyperLink><websitewithURL xlink:href="http://www.google.com"> Click to view website </websitewithURL></WebsiteAsHyperLink>

and iI have the following script, when ran it converts hrefshrefs into valid tags.., but it does not work on xlinksxlinks

If iI could get some help on how to alter it to look at all xlinksxlinks

main();

function main() {
   var doc = app.activeDocument;
   var elems = doc.xmlElements;
   var ruleSet = new Array (new Rule);
   __processRuleSet(elems[0], ruleSet);

   function Rule() {
      this.name = "Rule";
      this.xpath = "//websitewithURL [@href]";
      this.apply = function(elem, ruleProcessor) {
         var elemText = elem.texts[0];
         var linkURL = elem.xmlAttributes.itemByName("href").value;
         var linkSource = doc.hyperlinkTextSources.add(elemText);
         var linkDest = doc.hyperlinkURLDestinations.add(linkURL);
         doc.hyperlinks.add(linkSource, linkDest);
         return true;
      }
   }
}

I have xml in the following format:

   <WebsiteAsHyperLink><websitewithURL xlink:href="http://www.google.com"> Click to view website </websitewithURL></WebsiteAsHyperLink>

and i have the following script, when ran it converts hrefs into valid tags.. but it does not work on xlinks

If i could get some help on how to alter it to look at all xlinks

main();

function main() {
   var doc = app.activeDocument;
   var elems = doc.xmlElements;
   var ruleSet = new Array (new Rule);
   __processRuleSet(elems[0], ruleSet);

   function Rule() {
      this.name = "Rule";
      this.xpath = "//websitewithURL [@href]";
      this.apply = function(elem, ruleProcessor) {
         var elemText = elem.texts[0];
         var linkURL = elem.xmlAttributes.itemByName("href").value;
         var linkSource = doc.hyperlinkTextSources.add(elemText);
         var linkDest = doc.hyperlinkURLDestinations.add(linkURL);
         doc.hyperlinks.add(linkSource, linkDest);
         return true;
      }
   }
}

I have xml in the following format:

   <WebsiteAsHyperLink><websitewithURL xlink:href="http://www.google.com"> Click to view website </websitewithURL></WebsiteAsHyperLink>

and I have the following script, when ran it converts hrefs into valid tags, but it does not work on xlinks

If I could get some help on how to alter it to look at all xlinks

main();

function main() {
   var doc = app.activeDocument;
   var elems = doc.xmlElements;
   var ruleSet = new Array (new Rule);
   __processRuleSet(elems[0], ruleSet);

   function Rule() {
      this.name = "Rule";
      this.xpath = "//websitewithURL [@href]";
      this.apply = function(elem, ruleProcessor) {
         var elemText = elem.texts[0];
         var linkURL = elem.xmlAttributes.itemByName("href").value;
         var linkSource = doc.hyperlinkTextSources.add(elemText);
         var linkDest = doc.hyperlinkURLDestinations.add(linkURL);
         doc.hyperlinks.add(linkSource, linkDest);
         return true;
      }
   }
}
Source Link
lanes123
  • 197
  • 2
  • 12

Indesign - scriping xlink:href via scripts

I have xml in the following format:

   <WebsiteAsHyperLink><websitewithURL xlink:href="http://www.google.com"> Click to view website </websitewithURL></WebsiteAsHyperLink>

and i have the following script, when ran it converts hrefs into valid tags.. but it does not work on xlinks

If i could get some help on how to alter it to look at all xlinks

main();

function main() {
   var doc = app.activeDocument;
   var elems = doc.xmlElements;
   var ruleSet = new Array (new Rule);
   __processRuleSet(elems[0], ruleSet);

   function Rule() {
      this.name = "Rule";
      this.xpath = "//websitewithURL [@href]";
      this.apply = function(elem, ruleProcessor) {
         var elemText = elem.texts[0];
         var linkURL = elem.xmlAttributes.itemByName("href").value;
         var linkSource = doc.hyperlinkTextSources.add(elemText);
         var linkDest = doc.hyperlinkURLDestinations.add(linkURL);
         doc.hyperlinks.add(linkSource, linkDest);
         return true;
      }
   }
}