matth has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I can't find a perl theme to this question. Why does the following line of a .xml file, when displayed in emacs, show only the word author in blue and not the word list ???

<author_list>Noben-Trauth K., Naggert J.K., North M.A., Nishina P.M.</ +author_list>

I am just presuming that this does not matter.

Replies are listed 'Best First'.
Re: Emacs and colour of XML tags
by dreadpiratepeter (Priest) on Jan 07, 2003 at 20:58 UTC
    my guess would be that the mode has a regexp of something like /<\/?\w+/ for the coloration and doesn't recognize '_' as a word character. UPDATE: Forgot the standard "this has nothing to do with Perl and doesn't belong here, but I'll answer it for you anyway" disclaimer.

    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
      I guess what I am really asking is ..... Does any Perl XML modules behave in the same way? If the answer to this is yes, then I could have problems in the future.

        Hi Matth,

        this sounds more relevant to Perl Monks... No, the Perl XML modules will behave correctly. Sometimes emacs modes use rather simple methods to do syntax colouring, for ease of programming and speed. The XML:: suite of modules, however, is designed to behave correctly ;-). That is, if your input is valid XML, it should parse fine -- everything else would be a bug.

Re: Emacs and colour of XML tags
by osama (Scribe) on Jan 08, 2003 at 03:53 UTC

    just a XML small comment:

    I notice you use
    <author_list>Noben-Trauth K., Naggert J.K., North M.A., Nishina P.M.</author_list>
    
    won't you ever need the authors separately?

    why not have:

    <author_list>
       <author>Noben-Trauth K.</author>
       <author>Naggert J.K.</author>
       <author>North M.A.</author>
       <author>Nishina P.M.</author>
    </author_list>
    
      Once a paper is published, authors are very rarely added or removed.

        They are rarely added or removed but the list can certainly be displayed different ways: on a single line, one name per line. If the authors are tagged separately it might also be easier to do something clever with their name like generating a google search on their name, linking them to a bibliographical DB or just to their bio's.

        Granted it looks like a simple split /\s*,\s*/ would give you the list but the risk is that if an author name one day happens to include a comma (Sergio "The Good, The Bad and the Ugly" Leone maybe ;--) then your code will fail silently.

        In the end it is a trade-off between conveniency (not tagging individual author names might make it easier for the initial typist) and power.

        For people list I have nearly always seen each name tagged though