Problem with copy (and with move)

Help
2002-07-13
2002-08-05
  • Paul Hoffman

    Paul Hoffman - 2002-07-13

    I've just started using xsh and I'm very excited at what I'm going to be able to do with it.  I've found that using xsh in interactive mode is a huge help in learning XPath, much better than reading about XPath.

    However, I'm having a hard time figuring out how to make xsh's copy command do what I want -- I can't seem to make it copy more than one element at a time.  I installed the latest version via CVS but that didn't seem to make any difference.

    Here's a verbatim transcript from a recent session:

    % xsh -i
    -----------------------------------------------------
    xsh - XML Editing Shell version 0.9 (Revision: 1.6)
    -----------------------------------------------------

    Copyright (c) 2002 Petr Pajas.
    This is free software, you may use it and distribute it under
    either the GNU GPL Version 2, or under the Perl Artistic License.
    Using terminal type: Term::ReadLine::Stub
    Hint: Type `help' or `help | less' to get more help.
    xsh scratch:/> open sk=suinakalan.xml; open vx=vaux.xml
    parsing suinakalan.xml
    done.
    parsing vaux.xml
    done.
    xsh vx:/> count sk://e
    2046
    xsh vx:/> count vx://e
    1
    xsh vx:/> count sk://e[contains(.//s/text(), 'speak')]
    3
    xsh vx:/> count vx://e[last()]
    1
    xsh vx:/> copy sk://e[contains(.//s/text(), 'speak')] after vx://e[last()]
    xsh vx:/> count vx://e
    2
    xsh vx:/> copy sk://e replace vx://e
    xsh vx:/> count vx://e
    2
    xsh vx:/> move sk://e[contains(.//s/text(), 'speak')] after vx://e[last()]
    xsh vx:/> count sk://e
    2043
    xsh vx:/> count vx://e
    3

    Both sk and vx use the same DTD.  Am I confused, or is this a bug?

    Thanks very much,

    Paul.

    --
    Paul Hoffman <nkuitse AT umich DOT edu>

     
    • Paul Hoffman

      Paul Hoffman - 2002-07-14

      After some careful rereading of the help information, I'm able to answer my own question. You can use foreach:

      foreach sk://e[contains(.//s/text(), 'speak')] copy . after vx://e[last()]

      Or xcopy:

      xcopy sk://e[contains(.//s/text(), 'speak')] after vx://e[last()]

      Unless I'm mistaken, those two commands are equivalent.

      --
      Paul Hoffman <nkuitse AT umich DOT edu>

       
      • Petr Pajas

        Petr Pajas - 2002-08-05

        Yes, almost equivallent, xcopy should be a little bit faster than foreach copy.

        -- Petr Pajas

         

Log in to post a comment.