Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

XPath and Predicates limits : please help me !

$
0
0

Hi

 

Please take look to these examples script execute from Windows  InDesign CS4 :

 

Short multiple XPath predicates

 

var dataXML = new XML("<cahier><titre><unitorg><fonction><lf>e</lf></fonction><fonction><lf>vg</lf></fonction></unitorg></titre></cahier>");
var test_xpath = "/*[1]/*[1]/*[1]/fonction[lf='e' or lf='a' or lf='ad' or lf='va' or lf='ea']"; 
result = dataXML.xpath(test_xpath);
alert("result : "+result);

 

result is OK

 

<fonction><lf>e</lf></fonction>

 

Long multiple XPath predicates

I just changed the XPath (ad some "OR" conditions)

 

var dataXML = new XML("<cahier><titre><unitorg><fonction><lf>e</lf></fonction><fonction><lf>vg</lf></fonction></unitorg></titre></cahier>");
var test_xpath = "/*[1]/*[1]/*[1]/fonction[lf='e' or lf='a' or lf='ad' or lf='va' or lf='ea' or lf='gh' or lf='kj' or lf='rt' or lf='lk' or lf='ft' or lf='iu']"; 
result = dataXML.xpath(test_xpath);
alert("result : "+result);

 

ERROR : [ ] not closed !  ???

Long simple XPath predicates

I just replaced *[1] node by a nomnative node in my XPath

 

var dataXML = new XML("<cahier><titre><unitorg><fonction><lf>e</lf></fonction><fonction><lf>vg</lf></fonction></unitorg></titre></cahier>");
var test_xpath = "/cahier/titre/unitorg/fonction[lf='e' or lf='a' or lf='ad' or lf='va' or lf='ea' or lf='gh' or lf='kj' or lf='rt' or lf='lk' or lf='ft' or lf='iu']"; 
result = dataXML.xpath(test_xpath);
alert("result : "+result);

 

result is OK

 

<fonction><lf>e</lf></fonction>

 

Conclusion and Question ?

WHY ? I don't understand... If someone can give me an explanation !


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>