Programmatically generate InfoPath form template? - infopath

Is it possible to programmatically generate an info path 2007 form template (xsn file=form definition) ?
I know that there is no object model for the infopath 2007 form designer, but does anyone know of any third party libraries?
The form view itself is a xsl file so it should be possible. I would have thought that its a common use case also.

It is possible to generate the manifest.xsf, xsl and xml files from a structured source (let's say an xml) and then pack this (as .cab) with the extension .xsn
(The .xsn file is nothing but a renemed .cab!)
This is only a raw concept - it could be refined if the purpose was a bit more explicit. Why generate? Are you going to create a bunch of different files? What for?

There are no libraries or API's to do this. While generating a template is possible you will need to write it all yourself. Obviously this will not be an easy task and will be prone to errors. I would recommend reviewing your requirements to ensure this is truly necessary. InfoPath is quite flexible, without knowing the details of your project, there is a good chance you can get the functionality you need with a single template.

Related

Possible to search through all JSPs in Adobe CQ5 repository with CRXDE?

We have a couple of relatively simple websites running on Adobe CQ 5.5 that were developed by a third party. I'm pretty familiar with how CQ works, but I'm working with somebody else's code here and I need to be able to search through all components in the system for a particular string.
The issue is that I can't seem to find a way to search across all of the various .jsp files stored with the various system components. I would have figured that the query tool in CRXDE Lite would have done the trick with something like this:
/jcr:root//*[jcr:contains(., 'Find this exact string in a JSP')] order by #jcr:score
But I've had no luck.
What I am looking for is some sort of global search that includes JSP files. Is that possible? Were I using a regular Java system, any IDE worth the download would be able to do this.
Thanks.
Might not be easiest way, but you can use the VLT tool to checkout the repository into your filesystem. Then you can lookup using whatever tool you prefer. It might even be faster in the long run
I don't have the actual answer but I suppose the JSPs are indexed via a filter that strips out some of their content.
It should be possible to configure the repository to index them as is instead, based on the info at http://wiki.apache.org/jackrabbit/IndexingConfiguration and http://jackrabbit.apache.org/jackrabbit-text-extractors.html
Sorry about the vagueness of this answer - I know the basic principles but to provide the details I would need more time than I can afford now ;-)

ASP.NET + MVC4 - "faking" a model? working without a datatable

I'm not an ASP.NET programmer, but, as it happens in life, I had to do some minor projects using it. Now came another one in which I have to implement some custom solutions and I haven't figured it out yet - I need some tip or maybe a piece of advice like "don't go that way" ;)
Previously it was simple - there was a table in DB, there was an adequate model and a view that worked with it - worked like charm. Now it's a little bit more complicated.
The "site" is going to contain, shortly and generally speaking, a survey - but a fully configurable one, unfortunately. In another product there's gonna be a configuration manager that will allow user to define pages, block types, questions, steps and so on and will generate an XML.
For the time being, in accordance with the specification, in the site's database I'm going to have only one table which will contain just a key and the XML generated by the configurator (and maybe some additional, not important information). Now - I need to parse this XML and build the site containing pages and other elements corresponding to it.
And that WOULD not be a problem, but I don't really know how to work that way using asp.net + mvc and can't find any piece of advice that would help me anyhow. Should I create an object that would somehow fake being a model and allow me to work for example on a dataset generated from XML? Or just create a model of the mentioned table and work with the XML directly on the view (I don't like even such an idea itself)? Or - having to do something like that - just give up on MVC and use only "clear" ASP.NET? Or maybe something else?
I'll be very grateful for any help.
And I hope I described what I need understandably ;)
If the XML documents have a schema defined then you can easily generate a class that matches the document using the xsd.exe tool. The document can then be deserialized into an instance of that class using existing functionality in the .Net framework. Just google .Net Xml serialization :-)
Now, if you don't have a schema you could create one if you are sure that you know the format of the Xml. Alternatively you could create a class that matches the format you expect to get and then parse the Xml manually. This last option is much more work, so I wouldn't recommend it.
In any case, the class you end up with should contain all the data you need from the Xml document and can then be used as the Model in your MVC page. As long as you can use the standard Xml deserialization technique then this should be quite easy and painless.

Use an excel template and update it programatically

I found this tool but I wonder if it still the right way nowdays with net 4.0 or is there any straight forward oob alternatives.
I just need to add columns and update excel stuff programatically. There are many ways but I need to keep the original document as a template. The link above explains exactly what the requeriments are and why they created such "ExcelPackage" library.
A quick look at the link you provided seems like it will in fact keep the original template intact and just return a populated version of that template. This is a pretty common way to create and populate Excel documents using Open XML since it helps to minimize the amount of code you have to write. If you did not specify the layout, styles, formats, etc in a template you would be forced to define those when coding and that could lead to some bloated code. Overall, a project like this or using the Open XML SDK 2.0 to create the documents is the way to go.

Is there a better .NET template system than XSLT?

I am creating a web application that will need to send a variety of emails out to users. Instead of hard-coding the contents of the email in the app, I want to use a template stored on disk and replace tokens in it (ex. "Hello, %%FirstName%%!") with the actual data. I have some experience with creating XSLT templates, but since the data isn't naturally in XML format this may not be the best fit. Is there a better template tool in .NET?
Note that I prefer one built in to the language but I'd consider add-ons too.
Thanks,
Graham
I have personally use Spark. Its an easy to use text templating library (below is an example of Spark syntax)
<var names="new [] {'alpha', 'beta', 'gamma'}"/>
<for each="var name in names">
<test if="name == 'beta'">
<p>beta is my favorite.</p>
<else/>
<p>${name} is okay too I suppose.
</test>
</for>
It even comes with a sample code for email text templating which you could look at on github.
You may want to take a look at MVCContrib. They have an e-mail template system IEmailTemplateService that uses Views to render the actual e-mail message which gives you access to a lot of features, including different view engines. If you are not in an MVC environment, you could possibly still extract some useful tricks out there.
I am using NVelocity for that, and I find it's very flexible and easy to use. It not only allows you to replace tokes, but it also includes sort of a programming language, e.g. for conditionals (if) and loops (for, foreach).
The original project seems to be dead, but there is a fork maintained by the Castle project.
Of course there are lots of other, alternative template libraries (stringtemplate seems to be popular), as you can see in this question I asked some time ago.

Generating WordML Reports Using Templates and XPath using ASP.Net

I need to know how we can Generate WordML Reports Using Templates and XPath using ASP.Net.
What are its advantages.
A Simple How To Tutorial is what I require.
I need to know how we can Generate WordML Reports Using Templates and XPath using ASP.Net. ... A Simple How To Tutorial is what I require.
Create (using Word) a document in WordML format which you'll use as a template.
Look at your WordML template: see that it's in XML format. Have Microsoft's WordML reference documentation, so that you understand what it means and how to modify it.
Define XPath expressions which identify the locations in your template which you want to modify (where "modify" probably means "insert data at run time").
At runtime use an API like http://www.google.com/search?hl=en&q=c%23+xpath
What are its advantages.
Its advantages over what alternative?
The benefit is that the output is a Word document, whose content is based on a template plus modifications made at runtime.
I would recommend you to use Content Controls and Custom XML for the purpose of report generation. Here's a sample:
http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx
You might also want to have a look at Microsoft's OpenXML SDK v2.0

Resources