Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The links parameter is configured using script to spiderout to the additional URLs in the input document.  In the example, the script parameter is used to determine the behavior of follow web links when an additional URL is found in the input data.

 

Code Block
},
        {
            "links": {
                "script": "var  retVals = [];\nvar n = -1;\nvar url = 
_doc.url.replace(/[?].*/,\"\");\nvar start = 0;\nwhile (start < 
text.length) {\n    var end = text.indexOf('\\n', start);\n    if (end 
== -1) end = text.length;\n    var line = text.substr(start,end-1);\n     start = end + 1;    \n    \n    n++;\n    if (0 == n) continue;\n     \n    var title = 'line #' + n.toString();\n    var url2 = url + '#' +  n.toString();\n    var fullText = line;\n    var retVal = {  'title':title, 'url':url2, 'fullText':line };\n    retVals.push(retVal);
 \n}\nretVals;\n      "
            }
        },

 

For XML APIs the basic principle is the same, but the XML object needs to be parsed using embedded Java calls (since the Rhino javascript engine currently in use does not support e4x - it is on our road map to upgrade to a version that does).

...