Search code examples
xmlstructuremarkup

How to structure and markup dialogue in XML for a book?


I have some structure for a book that looks basically like this:

<chapter>
  <verse>Eva said, <quote speaker="Eva">I'm not the one who's underestimating her cleverness.</verse>
  <verse>Or maybe it's you I'm underestimating. Have you finally joined her side, sister?</quote></verse>
</chapter>

The problem, as you can see, is that I have quotes that need to span across multiple verses. How should I handle this? There might also be other tags (not just quote tags) that need to span verses and possibly—though unlikely—even chapters.

The XML will be parsed by some application that I am writing in a high-level language such as Go, Java, JavaScript, etc. I have full control over this.

Am I using an inappropriate markup language for the data I have? Or am I structuring the verses and other tags incorrectly?


Solution

  • Well it isn't going to parse that! Two options I can see, that would make more sense than what you have

    <chapter>
      <verse>Eva said, <quote speaker="Eva">I'm not the one who's underestimating her cleverness.</quote></verse>
      <verse><quote speaker="Eva">Or maybe it's you I'm underestimating. Have you finally joined her side, sister?</quote></verse>
    </chapter>
    

    Oh and I'd say that the comma after Eva said, is redundant

    or

    <voice speaker = default/>
    <chapter>
      <verse>Eva said, <voice speaker="Eva"/>I'm not the one who's underestimating her cleverness.</verse>
      <verse>Or maybe it's you I'm underestimating. Have you finally joined her side, sister?<voice speaker = default /></verse>
    </chapter>