7 Replies Latest reply on Jan 14, 2012 1:24 AM by Green4ever

    Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)

    Green4ever Level 3

      Hi All,

       

      The xpath "//backMatter/Ref/RefText[position()<10]" is not accepted in the function "app.xmlRuleProcessors.add()"

       

      But if I use evaluateXPathExpression("//backMatter/Ref/RefText[position() < 10]") I can get what I need.

       

      For all other thing I used glue code. So i cannot change the entire script because of this could anyone please give any idea?

       

      ----------------

      Green4ever

        • 1. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
          John Hawkinson Level 5

          Can you please post a reproducible test case?

          • 2. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
            Green4ever Level 3

            I have posted a reply to this thread but now it is not listed in the forums page also. I have searched this thread through Your stuff. Soon I'll post the reproduce test case.

            • 3. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
              Green4ever Level 3

              This is simplied script from my entire script, hope this will useful.

               

              #include "glue code.jsx"//use your absolute path to include this.
              var myDoc = app.activeDocument;
              //use xpathExpression some thing like this.... "//backMatter/Ref/RefText[position()<10]" 
              var myRuleSet = new Array (new ApplyStyleXpath("Your Para/Char Style Name", "XpathString", "para/char"/*Style type*/));
              with(myDoc)
                  {
                  var elements = xmlElements;
                  __processRuleSet(elements.item(0), myRuleSet);
                  }//end with
              
              function ApplyStyleXpath(styleName, myXPath, type){
                  pBar.msg("Processing ParagraphStyles: "+styleName);
                  this.name = "ApplyParaStyleXpath";
                  //XPath will match on every description in the XML structure.
                  this.xpath = myXPath;
                  this.apply = function(myElement, myRuleProcessor){
                          if (type == "para"){
                              myStyle = app.documents.item(0).paragraphStyles.item(styleName);
                              myElement.texts.item(0).applyParagraphStyle(myStyle, true);
                              }
                          else if (type=="char"){
                              myStyle = app.documents.item(0).characterStyles.item(styleName);
                              myElement.texts.item(0).applyCharacterStyle(myStyle, true);
                              }
                          else{
                              alert("Style type unknown, Please check for the style name: "+styleName);
                              }
                      }
                  return true;
              }
              

               

              Use this xml to import into indesign

               

              <?xml version="1.0" encoding="UTF-8"?><Article>
              <backMatter><Ack><AckHead>ACKNOWLEDGEMENTS</AckHead>
              <AckPara>Supported by NIH R01NS39821.</AckPara></Ack>
              <Ref><RefHead>REFERENCES</RefHead>
              <RefText><RefSlNo>1.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Bhatia</RefSurName><x> </x><RefGivenName>KP</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Marsden</RefSurName><x> </x><RefGivenName>CD</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>The behavioural and motor consequences of focal lesions of the basal ganglia in man</RefArticleTitle><x>. </x><RefJournalTitle>Brain</RefJournalTitle><x> </x><RefYear>1994</RefYear><x>; </x><RefVolume>117</RefVolume><x>: </x><RefFPage>859</RefFPage><x>–</x><RefLPage>76</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>2.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Marsden</RefSurName><x> </x><RefGivenName>CD</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Obeso</RefSurName><x> </x><RefGivenName>JA</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Zarranz</RefSurName><x> </x><RefGivenName>JJ</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>The anatomical basis of symptomatic hemidystonia</RefArticleTitle><x>. </x><RefJournalTitle>Brain</RefJournalTitle><x> </x><RefYear>1985</RefYear><x>; </x><RefVolume>108</RefVolume><x>: </x><RefFPage>463</RefFPage><x>–</x><RefLPage>83</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>3.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Feiwell</RefSurName><x> </x><RefGivenName>RJ</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Black</RefSurName><x> </x><RefGivenName>KJ</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>McGee-Minnich</RefSurName><x> </x><RefGivenName>LA</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Diminished regional cerebral blood flow response to vibration in patients with blepharospasm</RefArticleTitle><x>. </x><RefJournalTitle>Neurology</RefJournalTitle><x> </x><RefYear>1999</RefYear><x>; </x><RefVolume>52</RefVolume><x>: </x><RefFPage>291</RefFPage><x>–</x><RefLPage>7</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>4.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Perlmutter</RefSurName><x> </x><RefGivenName>JS</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Stambuk</RefSurName><x> </x><RefGivenName>MK</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Markham</RefSurName><x> </x><RefGivenName>J</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Decreased [18F]spiperone binding in putamen in idiopathic focal dystonia</RefArticleTitle><x>. </x><RefJournalTitle>J Neurosci</RefJournalTitle><x> </x><RefYear>1997</RefYear><x>; </x><RefVolume>17</RefVolume><x>: </x><RefFPage>843</RefFPage><x>–</x><RefLPage>50</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>5.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Vitek</RefSurName><x> </x><RefGivenName>JL</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Pathophysiology of dystonia: a neuronal model</RefArticleTitle><x>. </x><RefJournalTitle>Mov Disord</RefJournalTitle><x> </x><RefYear>2002</RefYear><x>; </x><RefVolume>17</RefVolume><x>: </x><RefFPage>S49</RefFPage><x>–</x><RefLPage>62</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>6.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Hallett</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>The neurophysiology of dystonia</RefArticleTitle><x>. </x><RefJournalTitle>Arch Neurol</RefJournalTitle><x> </x><RefYear>1998</RefYear><x>; </x><RefVolume>55</RefVolume><x>: </x><RefFPage>601</RefFPage><x>–</x><RefLPage>3</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>7.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Berardelli</RefSurName><x> </x><RefGivenName>A</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Rothwell</RefSurName><x> </x><RefGivenName>JC</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Hallett</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>The pathophysiology of primary dystonia</RefArticleTitle><x>. </x><RefJournalTitle>Brain</RefJournalTitle><x> </x><RefYear>1998</RefYear><x>; </x><RefVolume>121</RefVolume><x>: </x><RefFPage>1195</RefFPage><x>–</x><RefLPage>212</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>8.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Hallett</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Dystonia: abnormal movements result from loss of inhibition</RefArticleTitle><x>. </x><RefJournalTitle>Adv Neurol</RefJournalTitle><x> </x><RefYear>2004</RefYear><x>; </x><RefVolume>94</RefVolume><x>: </x><RefFPage>1</RefFPage><x>–</x><RefLPage>9</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>9.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Argyelan</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Carbon</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Niethammer</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Cerebellothalamocortical connectivity regulates penetrance in dystonia</RefArticleTitle><x>. </x><RefJournalTitle>J Neurosci</RefJournalTitle><x> </x><RefYear>2009</RefYear><x>; </x><RefVolume>29</RefVolume><x>: </x><RefFPage>9740</RefFPage><x>–</x><RefLPage>7</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>10.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Calderon</RefSurName><x> </x><RefGivenName>DP</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Fremont</RefSurName><x> </x><RefGivenName>R</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Kraenzlin</RefSurName><x> </x><RefGivenName>F</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>The neural substrates of rapid-onset Dystonia-Parkinsonism</RefArticleTitle><x>. </x><RefJournalTitle>Nat Neurosci</RefJournalTitle><x> </x><RefYear>2011</RefYear><x>; </x><RefVolume>14</RefVolume><x>: </x><RefFPage>357</RefFPage><x>–</x><RefLPage>65</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>11.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Niethammer</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Carbon</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Argyelan</RefSurName><x> </x><RefGivenName>M</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Hereditary dystonia as a neurodevelopmental circuit disorder: evidence from neuroimaging</RefArticleTitle><x>. </x><RefJournalTitle>Neurobiol Dis</RefJournalTitle><x> </x><RefYear>2011</RefYear><x>; </x><RefVolume>42</RefVolume><x>: </x><RefFPage>202</RefFPage><x>–</x><RefLPage>9</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>12.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Kemp</RefSurName><x> </x><RefGivenName>JM</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Powell</RefSurName><x> </x><RefGivenName>TPS</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>The corticostriate projection in the monkey</RefArticleTitle><x>. </x><RefJournalTitle>Brain</RefJournalTitle><x> </x><RefYear>1970</RefYear><x>; </x><RefVolume>93</RefVolume><x>: </x><RefFPage>525</RefFPage><x>–</x><RefLPage>46</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>13.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Fudge</RefSurName><x> </x><RefGivenName>J</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Kunishio</RefSurName><x> </x><RefGivenName>K</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Walsh</RefSurName><x> </x><RefGivenName>C</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Amygdaloid projections to ventromedial striatal subterritories in the primate</RefArticleTitle><x>. </x><RefJournalTitle>Neuroscience</RefJournalTitle><x> </x><RefYear>2002</RefYear><x>; </x><RefVolume>110</RefVolume><x>: </x><RefFPage>257</RefFPage><x>–</x><RefLPage>75</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>14.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Cherubini</RefSurName><x> </x><RefGivenName>E</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Herrling</RefSurName><x> </x><RefGivenName>PL</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Lanfumey</RefSurName><x> </x><RefGivenName>L</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Excitatory amino acids in synaptic excitation of rat striatal neurones in vitro</RefArticleTitle><x>. </x><RefJournalTitle>J Physiol</RefJournalTitle><x> </x><RefYear>1988</RefYear><x>; </x><RefVolume>400</RefVolume><x>: </x><RefFPage>677</RefFPage><x>–</x><RefLPage>90</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>15.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Alexander</RefSurName><x> </x><RefGivenName>GE</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>DeLong</RefSurName><x> </x><RefGivenName>MR</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Strick</RefSurName><x> </x><RefGivenName>PL</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Parallel organization of functionally segregated circuits linking basal ganglia and cortex</RefArticleTitle><x>. </x><RefJournalTitle>Ann Rev Neurosci</RefJournalTitle><x> </x><RefYear>1986</RefYear><x>; </x><RefVolume>9</RefVolume><x>: </x><RefFPage>357</RefFPage><x>–</x><RefLPage>81</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>16.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Wilson</RefSurName><x> </x><RefGivenName>CJ</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Groves</RefSurName><x> </x><RefGivenName>PM</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Fine structure and synaptic connections of the common spiny neuron of the rat neostriatum: a study employing intracellular injection of horseradish peroxidase</RefArticleTitle><x>. </x><RefJournalTitle>J Comp Neurol</RefJournalTitle><x> </x><RefYear>1980</RefYear><x>; </x><RefVolume>194</RefVolume><x>: </x><RefFPage>599</RefFPage><x>–</x><RefLPage>614</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>17.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Selemon</RefSurName><x> </x><RefGivenName>LD</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Goldman-Rakic</RefSurName><x> </x><RefGivenName>PS</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Longitudinal topography and interdigitation of corticostriatal projections in the rhesus monkey</RefArticleTitle><x>. </x><RefJournalTitle>J Neurosci</RefJournalTitle><x> </x><RefYear>1985</RefYear><x>; </x><RefVolume>5</RefVolume><x>: </x><RefFPage>776</RefFPage><x>–</x><RefLPage>94</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>18.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Flaherty</RefSurName><x> </x><RefGivenName>AW</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Graybiel</RefSurName><x> </x><RefGivenName>AM</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Corticostriatal transformations in the primate somatosensory system. Projections from phsyiologically mapped body-part representations</RefArticleTitle><x>. </x><RefJournalTitle>J Neurophysiol</RefJournalTitle><x> </x><RefYear>1991</RefYear><x>; </x><RefVolume>66</RefVolume><x>: </x><RefFPage>1249</RefFPage><x>–</x><RefLPage>63</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>19.</RefSlNo><RefAuthors><RefAuthor><RefSurName>McFarland</RefSurName><x> </x><RefGivenName>NR</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Haber</RefSurName><x> </x><RefGivenName>SN</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Organization of thalamostriatal terminals from the ventral motor nuclei in the macaque</RefArticleTitle><x>. </x><RefJournalTitle>J Comp Neurol</RefJournalTitle><x> </x><RefYear>2001</RefYear><x>; </x><RefVolume>429</RefVolume><x>: </x><RefFPage>321</RefFPage><x>–</x><RefLPage>36</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>20.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Hoshi</RefSurName><x> </x><RefGivenName>E</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Tremblay</RefSurName><x> </x><RefGivenName>L</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Feger</RefSurName><x> </x><RefGivenName>J</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>The cerebellum communicates with the basal ganglia</RefArticleTitle><x>. </x><RefJournalTitle>Nat Neurosci</RefJournalTitle><x> </x><RefYear>2005</RefYear><x>; </x><RefVolume>8</RefVolume><x>: </x><RefFPage>1491</RefFPage><x>–</x><RefLPage>3</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>21.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Mallet</RefSurName><x> </x><RefGivenName>N</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Le Moine</RefSurName><x> </x><RefGivenName>C</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Charpier</RefSurName><x> </x><RefGivenName>S</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Feedforward Inhibition of Projection Neurons by Fast-Spiking GABA Interneurons in the Rat Striatum In Vivo</RefArticleTitle><x>. </x><RefJournalTitle>J Neurosci</RefJournalTitle><x> </x><RefYear>2005</RefYear><x>; </x><RefVolume>25</RefVolume><x>: </x><RefFPage>3857</RefFPage><x>–</x><RefLPage>69</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>22.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Bouyer</RefSurName><x> </x><RefGivenName>JJ</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Park</RefSurName><x> </x><RefGivenName>DH</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Joh</RefSurName><x> </x><RefGivenName>TH</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>Chemical and structural analysis of the relation between cortical inputs and tyrosine hydroxylase-containing terminals in rat neostriatum</RefArticleTitle><x>. </x><RefJournalTitle>Brain Res</RefJournalTitle><x> </x><RefYear>1984</RefYear><x>; </x><RefVolume>302</RefVolume><x>: </x><RefFPage>267</RefFPage><x>–</x><RefLPage>75</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>23.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Sibley</RefSurName><x> </x><RefGivenName>DR</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Monsma</RefSurName><x> </x><RefGivenName>FJ</RefGivenName></RefAuthor></RefAuthors><x>. </x><RefArticleTitle>Molecular biology of dopamine receptors</RefArticleTitle><x>. </x><RefJournalTitle>Trends Pharm Sci</RefJournalTitle><x> </x><RefYear>1992</RefYear><x>; </x><RefVolume>13</RefVolume><x>: </x><RefFPage>61</RefFPage><x>–</x><RefLPage>9</RefLPage><x>.</x></RefText>
              <RefText><RefSlNo>24.</RefSlNo><RefAuthors><RefAuthor><RefSurName>Gerfen</RefSurName><x> </x><RefGivenName>CR</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Engber</RefSurName><x> </x><RefGivenName>TM</RefGivenName></RefAuthor><x>, </x><RefAuthor><RefSurName>Mahan</RefSurName><x> </x><RefGivenName>LC</RefGivenName></RefAuthor><x>, </x><RefEtal>et al</RefEtal></RefAuthors><x>. </x><RefArticleTitle>D<Sub>1</Sub> and D<Sub>2</Sub> dopamine receptor-regulated gene expression of striatonigral and striatopallidal neurons</RefArticleTitle><x>. </x><RefJournalTitle>Science</RefJournalTitle><x> </x><RefYear>1990</RefYear><x>; </x><RefVolume>250</RefVolume><x>: </x><RefFPage>1429</RefFPage><x>–</x><RefLPage>32</RefLPage><x>.</x></RefText>
              </Ref></backMatter></Article>
              

               

              Hope this is enough for you to reproduce the test case.

              • 4. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
                John Hawkinson Level 5

                Oh, I am Sorry!. I should have read your initial question more carefully:

                 

                 

                The xpath "//backMatter/Ref/RefText[position()<10]" is not accepted in the function "app.xmlRuleProcessors.add()"

                But if I use evaluateXPathExpression("//backMatter/Ref/RefText[position() < 10]") I can get what I need.

                See the XML Rules chapter of Scripting Guide, section XPath limitations:

                 

                XPath limitations
                InDesign’s XML rules support a limited subset of the XPath 1.0 specification, specifically including the following capabilities:

                   Find an element by name, specifying a path from the root; for example, /doc/title.

                   Find paths with wildcards and node matches; for example, /doc/*/subtree/node().

                   Find an element with a specified attribute that matches a specified value; for example,

                /doc/para[@font='Courier'].

                   Find an element with a specified attribute that does not match a specified value; for example,

                /doc/para[@font !='Courier'].

                   Find a child element by numeric position (but not last()); for example, /doc/para[3].

                   Find self or any descendent; for example, //para.

                   Find comment as a terminal; for example, /doc/comment().

                   Find PI by target or any; for example, /doc/processing-instruction('foo').

                   Find multiple predicates; for example, /doc/para[@font='Courier'][@size=5][2].

                   Find along following-sibling axes; for example, /doc/note/following-sibling::*.

                Due to the one-pass nature of this implementation, the following XPath expressions are specifically excluded:

                   No ancestor or preceding-sibling axes, including .., ancestor::, preceding-sibling::.

                   No path specifications in predicates; for example, foo[bar/c].

                   No last() function.

                   No text() function or text comparisons; however, you can use InDesign scripting to examine the text

                content of an XML element matched by a given XML rule.

                   No compound Boolean predicates; for example, foo[@bar=font or @c=size].

                   No relational predicates; for example, foo[@bar < font or @c > 3].

                   No relative paths; for example, doc/chapter.

                 

                So, basically, you can't do it that way. Sorry!

                1 person found this helpful
                • 5. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
                  Green4ever Level 3

                  Oh My God..!!!... I came across this xpath limitations more than a year ago, and now I forgotten this. Really thank you very much for pointing this out here.

                  But XMLElement.evaluateXPathExpression (using: string , prefixMappingTable:Array of varies) yields the result as expected. It means that evaluateXPathExpression is not limited to that specification. If yes, will it support Xpath 2.0?

                   

                  Thanks,

                  Green4ever

                  • 6. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
                    John Hawkinson Level 5

                    But XMLElement.evaluateXPathExpression (using: string , prefixMappingTable:Array of varies) yields the result as expected. It means that evaluateXPathExpression is not limited to that specification. If yes, will it support Xpath 2.0?

                    No. evaluateXPathExpression is normal XPath 1.0, without the restrictions.

                    The restrictions have something to do with the way XML rules are implemented, and some speed optimizations, I think.

                    There is no XPath 2.0 support in InDesign.

                    • 7. Re: Indesign CS5: Xpath 1.0 Not working inside rule processor (glude code script)
                      Green4ever Level 3

                      Thanks for the clarification John, Great information indeed. Hope In CS6 or later it will be available for the indesign users.