Cannot format MS Word 2003 File
Oxygen general issues.
-
- Posts: 9
- Joined: Thu Oct 29, 2009 1:51 pm
Cannot format MS Word 2003 File
I have:
- Opened Microsoft Word 2007
- Created a new document
- Inserted an image
- Saved the file as type: "Word 2003 XML document"
I now open the XML file in Oxygen. The XML file validates, however when I try to format the file, nothing happens i.e. the elements do not split onto new lines, indent, etc.
I regard myself as a fairly advanced Oxygen user and have never had any problems using the formatter before.
Here is a sample XML file created in Word: http://pastebin.com/DLxcLcwY
- Opened Microsoft Word 2007
- Created a new document
- Inserted an image
- Saved the file as type: "Word 2003 XML document"
I now open the XML file in Oxygen. The XML file validates, however when I try to format the file, nothing happens i.e. the elements do not split onto new lines, indent, etc.
I regard myself as a fairly advanced Oxygen user and have never had any problems using the formatter before.
Here is a sample XML file created in Word: http://pastebin.com/DLxcLcwY
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Cannot format MS Word 2003 File
Hello,
The sample XML file has on the root element(w:wordDocument) the attribute: xml:space="preserve". This attribute prevents Oxygen's Format and Indent tool from actually formatting the document.
Regards,
Adrian
The sample XML file has on the root element(w:wordDocument) the attribute: xml:space="preserve". This attribute prevents Oxygen's Format and Indent tool from actually formatting the document.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 9
- Joined: Thu Oct 29, 2009 1:51 pm
Re: Cannot format MS Word 2003 File
Adrian - great spot. Thanks for that.
In Word, I've found that you can't simply remove the xml:space="preserve" from the root element without messing up the document. The following transform will move the xml:space="preserve" from the <w:wordDocument> to each <w:t> - allowing you to indent the document without damaging the content.
In Word, I've found that you can't simply remove the xml:space="preserve" from the root element without messing up the document. The following transform will move the xml:space="preserve" from the <w:wordDocument> to each <w:t> - allowing you to indent the document without damaging the content.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2">
<xsl:template match="@*|text()|comment()|processing-instruction()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="w:t">
<xsl:copy>
<xsl:attribute name="xml:space">preserve</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="w:wordDocument">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:if test="name()!='xml:space'">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service