免责声明:以下是针对XML的罪行.这就是我试图用XSLT改变它的原因:)
我的XML目前看起来像这样:
<root>
<object name="blarg" property1="shablarg" property2="werg".../>
<object name="yetanotherobject" .../>
</root>
Run Code Online (Sandbox Code Playgroud)
是的,我将所有文本数据放在属性中.我希望XSLT能救我; 我想走向这样的事情:
<root>
<object>
<name>blarg</name>
<property1>shablarg</name>
...
</object>
<object>
...
</object>
</root>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我实际上已经完成了所有这些工作,除了我对XML的罪恶更加特殊.一些标签看起来像这样:
<object description = "This is the first line
This is the third line. That second line full of whitespace is meaningful"/>
Run Code Online (Sandbox Code Playgroud)
我在linux下使用xsltproc,但它似乎没有任何保留空格的选项.我试图使用xsl:preserve-space和xml:space ="preserve"无济于事.我发现的每个选项似乎都适用于在元素本身内保留空格,而不是属性.每一次,以上都改为:
This is the first line This is the third line. That second line full of whitespace is meaningful
所以问题是,我可以保留属性空白吗?