Copy link to clipboard
Copied
Hi ,
I am writing an javascript to find all <informalfigure> xml element that has no "type" attribute. When I run my script, it display an error message:
Error: Adobe InDesign cannot processXpath expression ""
my script is:
#target indesign-6.0
#include "glue code.jsx"
var myDocument = app.activeDocument;
var alltags = new Array;
var i1 = 0;
var myXPath = "//informalfigure[not(@type)]";
var myRuleSet = new Array (new ProcessProduct);
var myDoc = app.activeDocument;
with(myDocument) {
try {
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
}
catch (err) {
alert (err);
}
}
alert(alltags.length)
function ProcessProduct()
{
this.name = "ProcessProduct";
this.xpath = myXPath;
this.apply = function(myElement, myRuleProcessor) {
alltags[i1++] = myElement;
}
return true;
}
Can any one tell me where it is wrong.
Thanks,
Gopal
Copy link to clipboard
Copied
Aaagh!!! XPath Limitation in ID I guess.
Your XPath statement (I guess) is not supported in ID "//informalfigure[not(@type)]"
though you can do //informalfigure[@type]" or //informalfigure", but I can understand that you are interested only in "informalfigure" elements with no "type" attributes.
Copy link to clipboard
Copied
Dear PankChat
I'm having the doubt about can we use XML NameSpaces in Javascript. Is it possible?
In my XPath Statement is "ce:figure[@id]"
//======================= Start Script =======================//
#target indesign-6.0
#include "D:\\program files\\Adobe InDesign CS4\\Scripts\\XML Rules\\glue code.jsx"
var myDocument = app.activeDocument;
var alltags = new Array;
var i1 = 0;
var myXPath = "//ce:figure[@id]";
var myRuleSet = new Array (new ProcessProduct);
var myDoc = app.activeDocument;
with(myDocument) {
try {
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
}
catch (err) {
alert (err);
}
}
alert(alltags.length)
function ProcessProduct()
{
this.name = "ProcessProduct";
this.xpath = myXPath;
this.apply = function(myElement, myRuleProcessor) {
alltags[i1++] = myElement;
}
return true;
}
//======================= End Script =======================//
OutPut though InDesign : Error: Adobe Indesign cannot process ^1XPath expression '^2'
I checked so many ways, but I can't get the solution Please let me know your comments and suggestion...
Regards
T.R.Harihara Sudhan
Copy link to clipboard
Copied
Try changing your XPath statement
var myXPath = "//ce:figure[@id]";
to
var myXPath = "//figure[@id]";
Weird, I know but will work I hope. Let me know.
Copy link to clipboard
Copied
Dear Pankaj,
Many thanks for this quick mail, I already checked with what you mentioned in this blog. I got the nice answers.
But my queries and doubt regarding for this XMLNameSpace only. How to use the NameSpace in this particular area.
Please kindly check and let me know your suggestion / comments.
Regards,
T.R.Harihara Sudhan
Copy link to clipboard
Copied
Hi,
Can I also find and change attributes?
Sumit
Find more inspiration, events, and resources on the new Adobe Community
Explore Now