• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2646
  • Last Modified:

Using Word to create XSLT

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
dugjohnson
Asked:
dugjohnson
  • 5
  • 4
1 Solution
 
dugjohnsonAuthor Commented:
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
 
R7AFCommented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
dugjohnsonAuthor Commented:
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
 
R7AFCommented:
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
 
dugjohnsonAuthor Commented:
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
 
R7AFCommented:
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
 
dugjohnsonAuthor Commented:
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
 
R7AFCommented:
0
 
dugjohnsonAuthor Commented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now