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
Solved

Using Word to create XSLT

Posted on 2007-04-11
10
2,594 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 500 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Microsoft Excel Digital Signature 2 59
how to link excel with word 6 72
Transferring select excel data to a Word Document 5 69
Microsoft Word startup Issue 7 34
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

837 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