(function(){ // create a testing namespace globalObject["commentTrial1"] = {}; // use "cls" for convenience cls = globalObject["commentTrial1"]; cls.identify = function(){ print("you have called commentTrial1.identify()"); } cls.insertCommentBeforeRoot = function(text) { var doc = Application.activeDocument; // scrub to avoid interpolation of quotes var scrubText = text.replace(/\"/,"\\\" ); var commentNode = doc.createComment(text);
// from file:///C:/Program%20Files/Arbortext/Editor/docs/javadoc/aom/index.html // getDocumentElement() // This is a convenience attribute that allows direct access // to the child node that is the root element of the document. // For HTML documents, this is the element with the tagName "HTML". //var root = doc.getDocumentElement(); //root.insertBefore(commentNode); var nl = doc.getChildNodes(); var root; for (var i=0; i<nl.getlength(); i++)=" {<br="/> print(nl.item(i).getNodeType() + " " + nl.item(i).getNodeValue()); // 1 = Element // 8 = Comment if (nl.item(i).getNodeType() == "1") { root = nl.item(i); print("found root element"); break; } } var parentRoot = root.getParentNode(); //parentRoot.appendChild(commentNode); // places after closing tag parentRoot.insertBefore(commentNode, root);
} }) (); commentTrial1.insertCommentBeforeRoot("This comment should be before the root tag;" + " created by commentTrial1.insertCommentBeforeRoot()");
--
Oracle Email Signature Logo John Laurence Poole | Principal Software Engineer | 650.607.0853 Oracle User Assistance Engineering M/S 2op1070 500 Oracle Parkway Redwood Shores CA 94065-1677
Oracle Instant Chat: john.poole
The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation.