Menu

#1 Line counter

open
nobody
5
2006-02-10
2005-12-14
Nom
No

Feature request: line counter in struct ezxml.

unsigned int line; // line number on which this tag was opened (starting
from 0)

This field counts the number of newlines encountered before the opening
'<' of the tag and records that value for each tag. It is mainly useful for
error handling, as it allows the program to determine on what line an
unexpected tag occurs.

Discussion

  • Aaron Voisine

    Aaron Voisine - 2006-02-10

    Logged In: YES
    user_id=128429

    The current version, 0.8.5, already lists the approximate line number (can be
    thrown off a bit by entity substitutions) when a well-formedness error is
    detected. It is slightly slower in that it counts up the lines when the error occurs,
    but it doesn't require an extra int to be recorded for every tag, and only happens
    once when there is an error.

     
  • Aaron Voisine

    Aaron Voisine - 2006-02-10
    • status: open --> closed
     
  • Nom

    Nom - 2006-02-10

    Logged In: YES
    user_id=1036896

    Hmm. But there doesn't seem to be an accessor for passing the line number
    information back to the calling program.

    There are 3 types of errors that could be encountered: well-formedness,
    structural (ie doesn't comply with DTD) and semantic (document is well formed
    and complies with the DTD, but the content is not correct). In the case of the
    latter two, it would be nice to have access to the original line number to point
    the user to the correct place.

     
  • Nom

    Nom - 2006-02-10
    • status: closed --> open
     
  • Aaron Voisine

    Aaron Voisine - 2006-02-10

    Logged In: YES
    user_id=128429

    Yes, the only way to access it would be to parse the error message... not very
    convenient I agree, but it's there if you really need it. ezXML is not a
    validating parser, so it only detects well-formedness errors. Are you building
    a validator on top of ezXML? If so you can take a look at ezxml_err() and see
    how it is estimating the line number and duplicate that. You will probably
    need access to some of the interal structs and defines in ezxml.c to do
    something like that anyway. I really want to avoid adding any more variables
    to ezxml_t if I can help it. Each one increases the memory required for an
    entire document by a significant amount. ezXML is being used by several
    embedded projects.

     

Log in to post a comment.