I have XSLT file which I'd like to edit in Visual Studio (2010). The template is used to transform input data-XML to OpenXML format (MS Word document). Visual Studio is failing to format it properly (split to multiple lines and indent). Selected line on the screenshoot (starts with <wx:sect>
tag) is just mile-long and not affected by Edit > Format Document (Format Section)
. Inside this line is a whole description of Word document.
What i need to do (to install may be) so VS could format such file?
When saving to 2003 WordML, Word puts xml:space="preserve"
in the root node of the document to make up for their badly designed XML structure, this keeps the code from pretty printing in an Editor.
If it is removed, formatting the document will work.
Word uses this mainly to preserve whitespace in w:t
elements.
If for example you have the following WordML code:
<w:p>
<w:r>
<w:t>Test </w:t>
</w:r>
<w:r>
<w:t>test</w:t>
</w:r>
</w:p>
Word will ignore the space in the first w:t
and write Testtest, unless the preserve space attribute is present.
Best remove and add it using XSLT:
<xsl:attribute name="xml:space">preserve</xsl:attribute>