Disclaimer: the following is a sin against XML. That's why I'm trying to change it with XSLT :)
My XML currently looks like this:
<root>
<object name="blarg" property1="shablarg" property2="werg".../>
<object name="yetanotherobject" .../>
</root>
Yes, I'm putting all the textual data in attributes. I'm hoping XSLT can save me; I want to move toward something like this:
<root>
<object>
<name>blarg</name>
<property1>shablarg</name>
...
</object>
<object>
...
</object>
</root>
I've actually got all of this working so far, with the exception that my sins against XML have been more... exceptional. Some of the tags look like this:
<object description = "This is the first line
This is the third line. That second line full of whitespace is meaningful"/>
I'm using xsltproc under linux, but it doesn't seem to have any options to preserve whitespace. I've attempted to use xsl:preserve-space and xml:space="preserve" to no avail. Every option I've found seems to apply to keeping whitespace within the elements themselves, but not the attributes. Every single time, the above gets changed to:
This is the first line This is the third line. That second line full of whitespace is meaningful
So the question is, can I preserve the attribute whitespace?
See Question&Answers more detail:os