Pergunta

I'm reading an XML file where I have "whitespace-only text nodes":

<p>I <b>love</b> <i>Mozart</i>.</p>

In the above (simplified) example, there is whitespace (a single space) between the end tag and the start tag. I need to preserve that space.

When parsing in RapidXML, I am ONLY specifying "parse_comment_nodes", so I assume "parse_trim_whitespace" and "parse_normalize_whitespace" are NOT in effect. So I'm attempting to use the "xml:space" syntax:

<p xml:space="preserve">I <b>love</b> <i>Mozart</i>.</p>

...but it seems as if RapidXML doesn't respect that. As I loop through all the sibling nodes, I never see a node with a value of " ".

I've been reading (and re-reading) the documentation, and searching here on StackOverflow, but so far haven't figured out if this is a syntax issue on my part, or a RapidXML issue.

Foi útil?

Solução

Now I'm POSITIVE that RapidXML 1.13 doesn't support working around whitespace-only text nodes using the xml:space="preserve" attribute. I located a PATCH for this very issue on SourceForge:

Link to patch for RapidXML 1.13 whitespace-only text node bug

This patch corrects the problem of RapidXML simply never returning/skipping a valid node when it only contained whitespace. It DOES NOT enable use of the xml:space="preserve" attribute. That would be the preferable method of ENABLING the bugfix. Perhaps someone more familiar with the RapidXML project can make that change in the future.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top