Solved

Using Word to create XSLT

Posted on 2007-04-11
10
2,581 Views
Last Modified: 2012-05-05
I want to know if there is a way to create the xslt file needed to transform my XML data into a Word document using Word itself....and how to do it.
I control the data.  My clients will want the ability to create their own merge letters and documents.  Because of the flat nature of Word Mail Merge, it appears that I will need to either use Automation, or XSLT.  I would rather use the latter if possible.
I can provide the schema for Word, and the user can create their document dropping in the tags.  I can have them save it as XML.  Is there a way that I can take that saved Word XML document and turn it into xslt.  Not a problem if it has to be done programmatically, I can write that, but I don't want the users to have to go through and create their own xslt.  Or is there a way to save a Word document or template as xslt then use it on my xml data.
And to add to the mix, this has to work in 2003 or 2007.
0
Comment
Question by:dugjohnson
  • 5
  • 4
10 Comments
 
LVL 7

Expert Comment

by:gbahri
Comment Utility
0
 
LVL 1

Author Comment

by:dugjohnson
Comment Utility
Those links describe how to create Word documents using XSLT and XML.  That is where I am heading.  I want to use Word to create the XSLT file....actually for my clients to use Word to create the XSLT files, which I will then combine with XML extracts to create Word documents for printing.
Again, the problem is creating XSLT from Word so that it has the needed formatting, NOT creating the XSLT file by hand to generate a Word document.
0
 
LVL 13

Expert Comment

by:R7AF
Comment Utility
I imagine that you want the following. You have an xml-datasource, and then want to let a client create a Word document, and drag xml-fields into the Word document, similar to e.g. Dreamweaver with a datasource. The result is an xslt document, which can be applied to the xml data to create a Word document.

I don't know if this can be done in Word. You can try Infopath and/or Sharepoint Server. I believe those are made for stuff like this. Start with Infopath, and see how it works out for you.

Try the following links. This is probably not exactly what you are looking for, but it's a start.
http://office.microsoft.com/en-us/infopath/HA101514381033.aspx#4
http://msdn2.microsoft.com/en-us/library/aa662316(office.11).aspx
0
 
LVL 1

Author Comment

by:dugjohnson
Comment Utility
If it was just me and not 3000 clients I would do that, but I am not able to require InfoPath.  It does look interesting though.
0
 
LVL 13

Expert Comment

by:R7AF
Comment Utility
Try this:

1) Let the customer create an example Word document like they want it to be.
2) Provide them with names for all the data fields they can use, e.g. firstName, lastName, etc.
3) These data field names should be enclosed in % or # characters, which makes them easily replaceble.  
4) The customers should insert those fields (like %firstName%) into the document instead of the example firstname.
5) Let them save it as XML
6) Then they can upload it to your webserver
7) You parse the documents and create the XSLT by extracting the data field names from the word-xml file.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:dugjohnson
Comment Utility
I can even go a step further by having them attach the schema for my tables to Microsoft Word and just drop the XML tags into place.  The crux of the problem is your #7.
I want to know how to either
A) Have Word take that saved XML version and change it to an XSLT or
B) What do I need to do to turn that XML into an XSLT?   The XML has a LOT of stuff that doesn't look like an XSLT.  What is the process of turning a Word XML file into an XSLT?
0
 
LVL 13

Expert Comment

by:R7AF
Comment Utility
I suppose you use a webserver where the documents are uploaded. You can then use ASP/JSP/PHP - whatever - to replace the %firstName% and create proper <xsl:value-of> tags. I doubt if you can do this with XSLT alone.

Still, if you need to repeat rows of data, like in a table, it gets more complicated. I don't know if you need that?

(A) is not an option AFAIK.
0
 
LVL 1

Author Comment

by:dugjohnson
Comment Utility
As an aside, does anyone know if InfoPath comes with all versions of Microsoft Office as of 2003?  If it does that could solve the problem, but if my clients have to pay extra for it, then it is not a solution for me, unfortunately.
0
 
LVL 13

Accepted Solution

by:
R7AF earned 500 total points
Comment Utility
0
 
LVL 1

Author Comment

by:dugjohnson
Comment Utility
OK, I've solved my own problem, at least as much as is possible.
There isn't a good way to create XSLT from Word directly.  Microsoft does have an XSLT Inference tool
http://msdn2.microsoft.com/en-us/library/aa212886(office.11).aspx
that works with Word 2003 XML documents (even those saved as Word 2003 XML from Word 2007) but the XSLT is not quite as satisfying as I would like yet.
I will be posting some conversion code myself a little later once I get it all figured out, but I am awarding the points to R7AF just because they hung in, and did, actually, answer my sub-question.
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Microsoft Paint 10 58
Mail Merge/EMail 10 53
VBA code snippets in a Word 2016 document 3 49
Protection area in Word 2 22
There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now