Marklogic How to exclude multiple nodes in xml









up vote
2
down vote

favorite












I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.



[(fn:local-name() != ("Sources","Navigators")]


In Marklogic Qconsole:



 for $x in $uris
let $doc := fn:doc($x)
let $copymeta := <meta:Metadata>
$doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
</meta:Metadata>
let $newxml := <omd:record>
$copymeta
</omd:record>
return $newxml









share|improve this question



























    up vote
    2
    down vote

    favorite












    I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.



    [(fn:local-name() != ("Sources","Navigators")]


    In Marklogic Qconsole:



     for $x in $uris
    let $doc := fn:doc($x)
    let $copymeta := <meta:Metadata>
    $doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
    </meta:Metadata>
    let $newxml := <omd:record>
    $copymeta
    </omd:record>
    return $newxml









    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.



      [(fn:local-name() != ("Sources","Navigators")]


      In Marklogic Qconsole:



       for $x in $uris
      let $doc := fn:doc($x)
      let $copymeta := <meta:Metadata>
      $doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
      </meta:Metadata>
      let $newxml := <omd:record>
      $copymeta
      </omd:record>
      return $newxml









      share|improve this question















      I have syntax errors when exclude multiple nodes in element like "Sources" and "Navigators" nodes. But it works if I exclude only one node but not combine before returning the documents.



      [(fn:local-name() != ("Sources","Navigators")]


      In Marklogic Qconsole:



       for $x in $uris
      let $doc := fn:doc($x)
      let $copymeta := <meta:Metadata>
      $doc//meta:Metadata/*[(fn:local-name() != ("Sources","Navigators")]
      </meta:Metadata>
      let $newxml := <omd:record>
      $copymeta
      </omd:record>
      return $newxml






      marklogic






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 20:34









      grtjn

      14.7k11730




      14.7k11730










      asked Nov 9 at 19:43









      thichxai

      31926




      31926






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You have a open parenthesis too many in front of fn:local-name().



          However, you could also make use of the except keyword, and a prefix wildcard. You would use it like this:



          for $x in $uris
          let $doc := fn:doc($x)
          let $copymeta := <meta:Metadata>
          $doc//meta:Metadata/(* except (*:Sources, *:Navigators))
          </meta:Metadata>
          let $newxml := <omd:record>
          $copymeta
          </omd:record>
          return $newxml


          HTH!






          share|improve this answer



























            up vote
            2
            down vote













            The != operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as != to "Navigators", and when it finds a *:Navigators node, it evaluates as != to "Sources". And then you get all the nodes.



            If you aren't comparing node sequences (so except is not an option), then instead of !=, you can use fn:not(A = B) to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators")) should work as you expect.






            share|improve this answer




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232329%2fmarklogic-how-to-exclude-multiple-nodes-in-xml%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote



              accepted










              You have a open parenthesis too many in front of fn:local-name().



              However, you could also make use of the except keyword, and a prefix wildcard. You would use it like this:



              for $x in $uris
              let $doc := fn:doc($x)
              let $copymeta := <meta:Metadata>
              $doc//meta:Metadata/(* except (*:Sources, *:Navigators))
              </meta:Metadata>
              let $newxml := <omd:record>
              $copymeta
              </omd:record>
              return $newxml


              HTH!






              share|improve this answer
























                up vote
                1
                down vote



                accepted










                You have a open parenthesis too many in front of fn:local-name().



                However, you could also make use of the except keyword, and a prefix wildcard. You would use it like this:



                for $x in $uris
                let $doc := fn:doc($x)
                let $copymeta := <meta:Metadata>
                $doc//meta:Metadata/(* except (*:Sources, *:Navigators))
                </meta:Metadata>
                let $newxml := <omd:record>
                $copymeta
                </omd:record>
                return $newxml


                HTH!






                share|improve this answer






















                  up vote
                  1
                  down vote



                  accepted







                  up vote
                  1
                  down vote



                  accepted






                  You have a open parenthesis too many in front of fn:local-name().



                  However, you could also make use of the except keyword, and a prefix wildcard. You would use it like this:



                  for $x in $uris
                  let $doc := fn:doc($x)
                  let $copymeta := <meta:Metadata>
                  $doc//meta:Metadata/(* except (*:Sources, *:Navigators))
                  </meta:Metadata>
                  let $newxml := <omd:record>
                  $copymeta
                  </omd:record>
                  return $newxml


                  HTH!






                  share|improve this answer












                  You have a open parenthesis too many in front of fn:local-name().



                  However, you could also make use of the except keyword, and a prefix wildcard. You would use it like this:



                  for $x in $uris
                  let $doc := fn:doc($x)
                  let $copymeta := <meta:Metadata>
                  $doc//meta:Metadata/(* except (*:Sources, *:Navigators))
                  </meta:Metadata>
                  let $newxml := <omd:record>
                  $copymeta
                  </omd:record>
                  return $newxml


                  HTH!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 9 at 20:34









                  grtjn

                  14.7k11730




                  14.7k11730






















                      up vote
                      2
                      down vote













                      The != operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as != to "Navigators", and when it finds a *:Navigators node, it evaluates as != to "Sources". And then you get all the nodes.



                      If you aren't comparing node sequences (so except is not an option), then instead of !=, you can use fn:not(A = B) to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators")) should work as you expect.






                      share|improve this answer
























                        up vote
                        2
                        down vote













                        The != operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as != to "Navigators", and when it finds a *:Navigators node, it evaluates as != to "Sources". And then you get all the nodes.



                        If you aren't comparing node sequences (so except is not an option), then instead of !=, you can use fn:not(A = B) to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators")) should work as you expect.






                        share|improve this answer






















                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          The != operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as != to "Navigators", and when it finds a *:Navigators node, it evaluates as != to "Sources". And then you get all the nodes.



                          If you aren't comparing node sequences (so except is not an option), then instead of !=, you can use fn:not(A = B) to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators")) should work as you expect.






                          share|improve this answer












                          The != operator has unintuitive semantics. See this previous question. When the code finds a *:Sources node, it evaluates as != to "Navigators", and when it finds a *:Navigators node, it evaluates as != to "Sources". And then you get all the nodes.



                          If you aren't comparing node sequences (so except is not an option), then instead of !=, you can use fn:not(A = B) to get the intended effect. In this case, fn:not(fn:local-name() = ("Sources","Navigators")) should work as you expect.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 10 at 4:49









                          BenW

                          31817




                          31817



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232329%2fmarklogic-how-to-exclude-multiple-nodes-in-xml%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Darth Vader #20

                              How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                              Ondo