Thanks for sharing your findings. I'm sure they'll help others who are trying
to do the same.
---
S.Y.M. Wong-A-Ton
:
Forgot the important 5th point, the fact that the <html></html>tags are
necessary for proper rendering (without inner tags being exposed) of
formatted text. In this case:
<html>
<ul xmlns="
http://www.w3.org/1999/xhtml" style="MARGIN-TOP: 0px;
MARGIN-BOTTOM: 0px" type="disc">
<li>some things</li>
<li>more things</li>
</ul>
</html>
That's it. I will test for other formatting later, after producing
effective C# code behind the 'Convert' button. Your advice made this a less
daunting task.
--
Joe
:
No worries.
Hey Joe, if it is working as is, you do not need to go look up the specs for
XHTML. I think if you call the file .txt and reference it in the DOCX but
tell the DOCX that it is HTML, it should work. This is perfect, since you do
not have to add any additional tags for the XHTML data from InfoPath to work.
You can just use the contents of the RTF field as is.
If you have to store it in a file, I'd suggest just putting the RTF contents
in a file and trying it out like that without adding the extra tags. If that
does not work, then dig into the XHTML.
---
S.Y.M. Wong-A-Ton
:
Understood. I just stripped the <my:upFront> tags and it rendered this in
the holding place within the Word .docx:
<ul xmlns="
http://www.w3.org/1999/xhtml" style="MARGIN-TOP: 0px;
MARGIN-BOTTOM: 0px" type="disc">
<li>some things</li>
<li>more things</li>
</ul>
For me, this is progress. I will go looking for the other XHTML tags,
according to the spec.
Thanks so much.
--
Joe
:
You only need what's inside of my:upFront. But to include this in an HTML
file that is valid, I think you will have to add additional HTML tags like
BODY etc. I'm not sure what the exact specs are for XHTML, but you should be
able to find them on
www.w3.org. First try it without any extra tags, and if
that does not work, you'll have to make the HTML file XHTML valid.
---
S.Y.M. Wong-A-Ton
:
Your reply is particularly rapid, timely and enlightening. After a great
deal of research and reading, I just went through all of the steps laid out
in
http://openxmldeveloper.org/forums/Thread/2744.aspx
(Most relevantly, what follows)
These are the steps to attach RTF content to WordProcessingML document.
1. Create a rtf file (test.rtf) and place along with [Content_Types].xml
file or in a folder
2. Add an entry into [Content_Types].xml as
<Default Extension="rtf" ContentType="application/rtf" />
3. In the document.xml.rels file (in _rels folder), add an entry for
relationship to this file as.... (I will end it here)
Low and behold, .rtf does NOT work. I have been struggling all day to know
which to apply, and you clarified that immediately. Sorry if I
misinterpreted your otherwise clear instructions. I have already saved it as
a .htm file and will (manually) package accordingly. One question concerns
the exact method for extracting the XHTML data in an RTF control. What I
just did was to extract the entire OuterXML reference:
<my:upFront>
- <ul xmlns="
http://www.w3.org/1999/xhtml" style="MARGIN-TOP: 0px;
MARGIN-BOTTOM: 0px" type="disc">
<li>some things</li>
<li>more things</li>
</ul>
</my:upFront>
paste this to Word 2007 and save it as a .htm file. Should I include all of
the above, such as the namespace?
Thanks again. You are making my day, late as it is (c. 10:30P EST).
--
Joe
:
Before you dive into code, did you manually try adding the contents of an
XHTML file to a DOCX? If that does not work, then it does not make sense to
try to do it via code.
To retrieve the XHTML of an RTF field in InfoPath, you need to use
SelectSingleNode() to retrieve the node for the RTF field and then use
InnerXml instead of Value to retrieve the XHTML contents of that field. You
can then use normal System.IO classes to write that XHTML data to either a
Stream or a file. The contents of an RTF field in InfoPath is XHTML. This is
HTML that conforms to a standard, so to save this to a file, the file would
become a .htm or .html file and *not* a .rtf file.
---
S.Y.M. Wong-A-Ton
:
Hi again,
My major 'mental block' is less on the packaging of the parts, including
additions to Content_Types.xml, document.xml.rels, etc., or even how to
supplement the current C# code behind the InfoPath form's "Convert to Word"
button in order to handle this. Rather, it is with the actual creation of
the .rtf (or is it .xhtml?) file, which contains the XHTML-formatted, aFChunk
data (e.g., a <ul> bullet list) that will be added to that package. Even
some example to illustrate the way to select the form's RTF control(s) from
other controls in the data source, and to properly stream/write the data to
the .rtf file, would be helpful at this stage.
Any further guidance, concerning these issues, will certainly help me
navigate this new territory and it will be most appreciated.
Thanks for your consideration.
--
Joe
:
Hi Joe,
Have you already tried posting this question in the Word newsgroup? People
might have more ideas there...
I'm not a Word expert, but I think your options are limited here.
I also
read about the afChunk element. It seems like a viable solution. However,
I've not tried it out.
What you could do is extract the XHTML of the rich text field of an InfoPath
form and then manually try to embed it in a DOCX file using the afChunk
element just as an isolated test. If that works, you can keep your existing
transformation using the XSL method and then after the transformation use the
System.IO.Packaging objects to create a relationship and add the XHTML for
the rich text to the package.
Other than that, I do not have any suggestions, but it's worth a try. Let us
know if it works; I'm sure there are many more people out there wanting to do
the same...
---
S.Y.M. Wong-A-Ton
:
Thanks to a S.Y.M Wong-A-Ton 'recipe,' a weekly status report form is
accurately converting string and date types through use of XSLT and C# when
the Word .docx version of this report (differently formatted with company
logo, etc.) is opened. However, data entered in the form's rich text
controls understandably lose their formatting (e.g., end of paragraph/line
breaks, lists, font display characteristics). The question is how to modify
the .xsl file or use an alternative approach for transformation. With the
former, I tried integrating xml code from a technique described by Stephane
Bouillon for the 2003 versions of each app, but that probably failed due to
2003 vs 2007 compatibility issues. Stephane suggested looking at Brian
Jones' explanation of Content Controls. I explored that for awhile and it
led to the Open XML 'alternative format chunks' specification. This seems
like a fascinating and powerful method, but I am looking for the IP --> Word
integration aspect, whiooich is not addressed in the content I have thus far
discovered.
Does anyone have any suggestions for moving me along the path to resolution
of this issue, or better yet, some applicable example(s)?
Thanks for your consideration,
Joe