?
Solved

Using Word to create XSLT

Posted on 2007-04-11
10
Medium Priority
?
2,618 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 7

Expert Comment

by:gbahri
ID: 18889746
0
 
LVL 1

Author Comment

by:dugjohnson
ID: 18890085
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
ID: 18892148
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:dugjohnson
ID: 18892791
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
ID: 18893600
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
 
LVL 1

Author Comment

by:dugjohnson
ID: 18893704
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
ID: 18893873
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
ID: 18893903
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 1500 total points
ID: 18900497
0
 
LVL 1

Author Comment

by:dugjohnson
ID: 18900970
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Suggested Courses

770 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