[Expat-discuss] Re: attribute line numbers?

Carlos Pereira carlos@pehoe.civil.ist.utl.pt
Mon Oct 15 12:11:09 2001


>Carlos Pereira writes:
> > When I find a wrong attribute (detected by my own app code),
> > is there a way to know the file line where that attribute
> > actually was?
>
>  XML_GetCurrentLineNumber() is as close as you can get; sorry.  Even
>if Expat gave you the line number for the name= portion of the
>attribute, that could be many (albiet blank) lines from the problem as
>well, so I think it unlikely that the problem is really solved with
>just the line number.  If the source uses an encoding your application
>understands, the start of the element is really enough to locate the
>attribute value (if using namespaces, make sure you hook the namespace
>callback so you can track prefixes for proper decoding).
>
>-Fred

Thanks, 

Showing the attribute name (which is unique for each element)
and the line number of the element is enough for users to detect mistakes.

Anyway, I thought Expat could have
a second array, for example:

int *line = XML_GetAttributeLineNumbers(parser);
printf("Wrong attribute name %s at line %d\n", attribute[i], line[i]);

The line numbers for the attribute name and the attribute value
could be different, as you said, so in general line[i] != line[i+1]

I am NOT saying that this is a good ideia, just asking...
Would this "feature" have an impact in Expat speed?
(after all you still have to count the lines...)
I certainly want to see Expat keeping the crown as 
the fastest XML parser under the sun... :-)

Carlos