Checking a file for well-formedness using the command line

Discussion in 'XML' started by Uwe Ziegenhagen, Oct 25, 2007.

  1. Hi,

    we use ATOX to generate XML from ASCII text. However the created
    documents are not always well-formed as some tags are misplaced. How can
    I check from the command line under Linux, if the file is well-formed?

    I would prefer a small executable, not a big framework...

    Thanks in advance,

    Uwe
     
    Uwe Ziegenhagen, Oct 25, 2007
    #1
    1. Advertising

  2. Almost every XML parser comes with a tiny sample program which
    demonstrates how to invoke it, and which will report well-formedness
    errors and/or validity errors. You should be able to adapt that sample
    to your needs. (Of course the parser itself may not be very small, but
    the sample will be.)

    Look at the user's clues for your favorite parser. If you don't have a
    favorite, I'd suggest the Apache Xerces parsers since they're free and
    high-quality and honor all the standards... but I'm a bit biased.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Oct 25, 2007
    #2
    1. Advertising

  3. In article <-berlin.de>,
    Uwe Ziegenhagen <> wrote:

    >we use ATOX to generate XML from ASCII text. However the created
    >documents are not always well-formed as some tags are misplaced. How can
    >I check from the command line under Linux, if the file is well-formed?


    >I would prefer a small executable, not a big framework...


    Try RXP:

    http://www.cogsci.ed.ac.uk/~richard/rxp.html

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Oct 25, 2007
    #3
  4. Uwe Ziegenhagen

    Pavel Lepin Guest

    Uwe Ziegenhagen <> wrote in
    <-berlin.de>:
    > we use ATOX to generate XML from ASCII text. However the
    > created documents are not always well-formed as some tags
    > are misplaced.


    No idea what ATOX is, but 'misplaced tags' indicates you're
    going about it the wrong way. XML as you know it is just a
    serialisation of a data structure. Tags don't really come
    into it. Generate a tree of nodes, serialise it, and unless
    you serialiser is borken, you won't have any 'misplaced
    tags' problems.

    > How can I check from the command line under Linux, if the
    > file is well-formed?
    >
    > I would prefer a small executable, not a big framework...


    libxml2 package comes with most if not all major Linux
    distributions. Chances are, you already have it installed.
    xmllint is a command-line validating parser (with XInclude
    processor and god knows what else slapped on top of it)
    that comes with it.

    --
    It is rare to find learned men who are clean, do not stink,
    and have a sense of humour. -- Liselotte in a letter to
    Sophie, 30 Jul 1705
     
    Pavel Lepin, Oct 26, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gustaf Liljegren
    Replies:
    0
    Views:
    1,360
    Gustaf Liljegren
    Jun 24, 2003
  2. sylvain.loiseau
    Replies:
    0
    Views:
    420
    sylvain.loiseau
    Oct 29, 2003
  3. Urs Muntwyler
    Replies:
    2
    Views:
    1,860
    Martin SChukrazy
    Mar 5, 2004
  4. Stanimir Stamenkov
    Replies:
    5
    Views:
    2,793
    Stanimir Stamenkov
    Apr 10, 2009
  5. luca
    Replies:
    3
    Views:
    393
    Robin
    Nov 21, 2010
Loading...

Share This Page