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;
}
}
}