1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unsuppressable errors from XML functions

Discussion in 'Support' started by cytc, Jun 25, 2011.

Thread Status:
Not open for further replies.
  1. cytc

    Joined:
    Jun 24, 2011
    Messages:
    2
    Likes Received:
    0
    Hi,

    I'm having a really hard time with the XML functions, specifically @XMLNODES. My XML looks like this (much simplified here):

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <storages>
      <storage id="A">
        <container id="1"></container>
      </storage>
      <storage id="B">
        <container id="2"></container>
        <include storage_id="A" />
      </storage>
    </storages>
    I've used the sample code from help file "XML in TCC" and tried to query number of optional nodes, in this case <include />. If I call:

    Code:
    @echo off
    set _bla=%@XMLOPEN[xmltest.xml]
    echo 1. # includes under B: %@XMLNODES[/storages/storage[@id="B"]]
    echo 2  Any includes under B? %@XMLXPATH[/storages/storage[@id="B"]/include]
    echo 3. # includes under A: %@XMLNODES[/storages/storage[@id="A"]]
    echo 4. # of storages: %@XMLNODES[/storages]
    :: everything below throws an unsuppressable error
    echo 5. Any includes under A? %@XMLXPATH[/storages/storage[@id="A"]/include] > NUL
    echo 6. %@XMLXPATH[/storages/storage[@id="A"]/include] || echo code: %_?
    echo 7. %@XMLXPATH[/storages/storage[@id="A"]/include] >&> NUL || echo code: %_?
    echo 8. # of foobar: %@XMLNODES[/foobar] >&> NUL
    set _bla=%@XMLCLOSE[]
    
    Echo 1-4 work fine and I was expecting Echo 5-8 to generate an error, but also set the var _?. However, the shown error "TCMD: (XML) Line: 0; Char: 0" is an unsuppressable one. No matter what I do, I cannot suppress it: adding "> NUL" to line, putting the line into another batch and call with call or even %@execstr[]. I suspected MSXML parser und upgraded it but it wasn't the cause. The error is simply unkillable. Since this is part of a menu-driven batch, it destroys the layout.

    How can I suppress this error?

    Thanks in advance!
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Unsuppressable errors from @XMLNODES

    ---- Original Message ----
    From: cytc
    |...
    | Code:
    |
    ?
    ?

    |...
    | However, the error "TCMD: (XML) Line: 0; Char: 0" is an unsuppressable
    | one. No matter what I do, I cannot suppress it:
    | adding "> NUL" to line...
    |
    | How can I suppress this error?

    By redirecting STDERR, not STDOUT - use ">&>" (or "2>" as in *nix), just as specified in HELP under Redirection!
    --
    Steve
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    Re: Unsuppressable errors from @XMLNODES

    I tried it. The error message is going to stderr, but redirection doesn't seem to work...?
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    Re: Unsuppressable errors from @XMLNODES

    The error message is generated when the line is parsed (it is never **executed**) so it would seem that redirection is not (yet) in effect. If it's similar to the error below it can be redirected with a command group.

    Code:
    v:\> echo %@eval[- [5]] 2> NUL
    TCC: Syntax error "- [5]"
    
    v:\> ( echo %@eval[- [5]] ) 2> NUL
    
    v:\>
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    Re: Unsuppressable errors from @XMLNODES

    Neat!
     
  6. cytc

    Joined:
    Jun 24, 2011
    Messages:
    2
    Likes Received:
    0
    Re: Unsuppressable errors from @XMLNODES

    The parentheses did the trick, thank you!
    Cheers :)
     
Thread Status:
Not open for further replies.

Share This Page