General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Display the line number of ajn object

  • tibo1981

    Display the line number of ajn object

    Participants 0
    Replies 1
    Last Activity 12 years, 6 months ago

    Hi there,

    Is there any way to get the line number of an XMetaL object (Selection, Element)?
    I'd like to generate a console containing every error message following the call of a macro; and for each error display the line number of the current document where this error happens.

    I'd be thankful for any help,

    Tibo

    Reply

    Derek Read

    Reply to: Display the line number of ajn object

    There is no API provided that will give this information to you directly as there is no concept of line numbers in TagsOn or Normal view. Line numbers are only make sense (they actually exist) after saving or after switching to Plain Text view. It is at that point that the DOM tree representing the XML document is turned into an XML string (with or without pretty printing having been applied).

    The best I can think of might be to try the following in a script:

    1) Place something into the document, perhaps a PI, that is uniquely identified.
    2) Grab the Xml property from a Document object and put it in a string.
    3) Parse that string line by line (how this is done may depend on the scripting language being used, and in any language there are probably different ways to do this) until you find the line containing the thing you put in during step 1.
    4) Remove the thing you put in at step 1.

    One drawback to this is that this will change the undo stack (because the document needs to be modified before you check Document.Xml). It also assumes that the document at some point has been pretty printed. If is has not been then the document will consist of one line only and so the value you get back after this for every error will be “line 1”.

    I also do not see exactly how you will connect the line number to a particular error, assuming that error is being raised by the XMetaL validation process.

    The PI you insert will also be visible to the user, however, that could likely be worked around by making this particular type of PI invisible using display:none in CSS.

    I suspect there may be other ways to get what you need, including 3rd party tools that might be employed.

    It sounds like you are trying to replace the Validation Log. Is there a specific issue with it that you are attempting to address? Or perhaps you are not working with XMetaL Author?

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support