Wednesday, 6 June 2007

Dynamics NAV 5.0 - Send to Application Feature - The Continuing Saga

Did you ever start something and wish you hadn't?

I thought it would be fun to blog about Dynamics NAV 5.0. I thought it would be easy to write a short posting following the investigation of new features. Why oh why did I start with the send to application feature? It has turned out to be far more work than I had expected. Oh well...

First of all, I would like to mention that I have already written too many posts on this subject. You can see them all by clicking the Send to Application Label on this blog. I won't say how many there are because, no doubt, I will need to add more when I finally figure things out.

I think I should mention Mark Brummel's Reporting from TechEd 2007 posting in which he says:

One of the issues with the office xml interface is that the changing of the stylesheets is very difficult unless you like reading xml schema's.

Fortunately they have changed that and added a stylesheet manager that allowes you to create them in a wysiwyg way. Great! It will be released shortly but there is no official date.

If you have been reading my posts on this topic, you will know that you probably already have a wysisyg editor for the stylesheets needed to transform xml data to Word documents - that is - Word itself. The more I look at the results of using the wml2xslt transform inference tool and compare this to the example stylesheets supplied with NAV 5.0, the more I think that maybe this is not going to work - it looks as though someone really did code this sample stylesheets by hand. I still can't get elements from within the same node to appear in different parts of the document. If anyone has any ideas, please post a comment.

Now the reason I am writing another post on this topic is the changes I suggested making to codeunit 403 will break the standard stylesheets that come with the CRONUS database. Oops.

I have figured out a way to create the stylesheet without hacking the codeunit that also leaves the existing stylesheets in their current working form.

To start with - don't edit codeunit 403 to add the xmlns attribute. Instead, generate the Customer Raw xml file as described but then open the xml file in notepad and manually add the xmlns="NAV" attribute at the end of the Object opening tag.

Now you can follow the previous instructions for creating the Customer Seed xml file (although I still haven't figured out how to use same elements in different parts of the document.)

Finally, use Notepad to open the Customer Seed xsl file (the transform that is generated by the wml2xslt utility) and find the xmlns attribute for the "NAV" namespace. When I tried this, it was ns0 as follows:

... xmlns:ns0="NAV"

Use search and replace to replace all ocurrences of "ns0:" with "" (ignore the quotes so you are replacing it with blanks.) Save the edited xslt file and you're done.

You should now be able to use this xslt file to transform the NAV xml as required - and all your standard stylesheets will still work. Phew!


Anonymous said...

Dear Mr Roys,
Thank you for the gread description how to create the XSLT files.
In this blog you write about the the wysiwyg editor for stylesheets. Could you tell me if the tool is release and where I can find it?

Jeannot Keiser

Gaspode said...

Hi Jeannot, thanks for the comment. This post was a long long time ago and I can't believe I didn't post a link to the tool. The link is on Kine's blog post here. Cheers, Dave.