Jump to content

Poetry/verse In Xml


mattropolis

Recommended Posts

I'm trying to put a number of poems and hymns (200-500 individual poems) into xml. However, the line formatting is obviously important - such as:this might bethe bestpoemever known to man.Obviously it won't do to have:this might be the best poem ever known to man.How does one embed lines without having to put explicit breaks for each line:<poem><text><line>this might be</line><line>the best</line><line>poem</line><line>ever known to man</line></text></poem>Since there are several hundred of these - adding all those line breaks would be painful (albiet I could write a program to parse it for me...Thanks in advance

Link to comment
Share on other sites

There are two ways you can achieve this.One is by adding an element for every line as you suggested already. I'd suggest "l" as the name, since it's shorter... besides preserving lines, this also enables you to process each line separately in any XML environment e. g. XSLT 1.0.The other is by using xml:preserve on elements that have text content with whitespace to be preserved. You are preserving lines for XML environments, but be aware that they'll see it as one node, so if you require to process a line separely, not all XML environments will work for you. E.g. XSLT 1.0 won't work, but XSLT 2.0 will.Examples of cases where you might want to process a line separely is if you want to add line numbering, count lines, bolden/indent a non-first line or something like that. Cases like boldening and indenting the first line are fortunatly covered by CSS.

Link to comment
Share on other sites

There are two ways you can achieve this.One is by adding an element for every line as you suggested already. I'd suggest "l" as the name, since it's shorter... besides preserving lines, this also enables you to process each line separately in any XML environment e. g. XSLT 1.0.
Yep - but the suggestion as a single character is a good idea to save space as I'm looking at probably several megabytes of text.
The other is by using xml:preserve on elements that have text content with whitespace to be preserved. You are preserving lines for XML environments, but be aware that they'll see it as one node, so if you require to process a line separely, not all XML environments will work for you. E.g. XSLT 1.0 won't work, but XSLT 2.0 will.Examples of cases where you might want to process a line separely is if you want to add line numbering, count lines, bolden/indent a non-first line or something like that. Cases like boldening and indenting the first line are fortunatly covered by CSS.
This sounds perfect - I don't need to count lines, indent/etc. Just display the text as I had it input. I'll give it a try...
Link to comment
Share on other sites

Opps... I'm sorry, but I just noticed I've given you a wrong attribute and value. The attribute (and it's value) is xml:space="preserve", e.g.

<text xml:space="preserve">this might bethe bestpoemever known to man.</text>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...