0 Replies Latest reply on Jul 2, 2013 2:28 AM by sr_bsw

    XPath and Predicates limits : please help me !

    sr_bsw

      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 !