Question

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?

Was it helpful?

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>

OTHER TIPS

I think you'd be best advised to adopt the docbook standard. An enormous amount of work has already gone into its schema, enabling it to support all forms of printed document.

In your case you could use one of the following docbook xml elements:

Docbook is used for documenting high profile projects, such as the Linux Kernel and Ubuntu. It can however be intimidating to use.

I prefer to use simpler text based markup languages (markdown, asciidoc). These have tools available to generate docbook. This gives me the best of both worlds, simplicity of use and support for professional publishing standards.

The problem is the structure. Your XML is not valid.

Instead of trying to put the quote elements inline with the verses, I'd suggest using an index that spans the entire document. That way, you could decouple the quote elements from the verse elements. So, for example, you might have a quote that looks like this:

<quote speaker="Eva" start=11 end=89/>

OR

<quote speaker="Eva" start=11 length=78/>

This way, you don't need to worry about your quotes spanning multiple verses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top