Generate HTML files using XML configuration - java

My target is to assemble a static web site that has a lot of repeating code. Now, I could use JSP includes for that purpose. But the site will be modified infrequently and under very heavy load, also using features like gzip and I don't need the complications.
My idea is to put up a build process with some tool like ant, That build process will concatenate all HTML pieces, preprocess HTML, JS, CSS with minifier and finally apply gzip.
I want an XML configuration that will define the parts that need to go in every html page and their order.
I need advice on ant or any similar tool; how to approach the configuration, any external tools that will help? Any suggestions are much appreciated.

XSLT is perfectly suited to transform XML into another format like HTML.
You can download Apache Xalan to give it a try. Ant has support for XSLT processing.

In the java world, you can take a look at Apache Forrest, which precisely do that kind of things.
In other worlds, there also exist webgen, which is a competent Ruby site builder.
I also vaguey remember there are other alternatives, but i can't find back their name.

Related

extract an XML schema (or equivalent) from a large set of xml files

I have 46000 xml files that all share a common structure but there are variations and the number of files makes it impossible to figure out a common xml schema for all of them. Is there a tool that may help me to extract a schema from all these files or at least something that may give me a close enough idea of what is mandatory and what is optional?
Preferably, of course, a schema according to some standard or a DTD.
And, as I work entirely in Linux, a Linux tool or a program that works in Linux is OK. I am quite fluent in C, Java, Javascript, Groovy, Python (2.7 and 3) and a number of other languages.
Looking deeper into the problem and after scanning other posts I found out that inst2xsd is the tool for this kind of tasks.

Java CSS spriting library

I'm looking for a pure Java CSS spriting library that I can integrate into my Maven build, so that spriting would be done automatically for every new build. (I'm currently using http://code.google.com/p/wro4j/ for JavaScript and CSS minimizing)
I was looking into http://csssprites.org/ first but the CSS annotation effort required somewhat put me off. Is there any other library out there I should be looking at?
Although not 100% ideal, I went for SmartSprites in the end. There's a nice Jangaroo Maven Plugin, meaning you can integrate the Sprite generation into your Maven build process easily.
Downside of this solution is, that you have to add quite a bit of extra hints into your CSS files, so SmartSprites can do its spriting. Would have been nice, if SmartSprites would (semantically) parse the CSS files and do the spriting automatically.
I don't know if this is exactly what you're looking for. This can create sprite sheets and export the data in many different formats. I posted to it because it has a command line version of it that may be of use.
http://www.texturepacker.com
http://www.texturepacker.com/store/

Simple way to apply template to existing HTML code

Suppose I have a bunch of (very simple) HTML pages, that I want to apply a common 'theme".
These files are downloaded using various Groovy scripts, and I would like to apply to them this styling during a maven build. How could I do that ?
Using which framework/library could I do that ?
Furthermore notice I want to do that in a static fashion, that's to say I want to have the following process to occur
Files are downloaded by Groovy scripts
They are processed (in a "magical" fashion) by this library
They may be sent by FTP/SCP to an hosting server
Do you know such an easy to use library ?
Depends on the details of the task but having in mind the steps you've described you can consider using velocity templates.
I would suggest using sitemesh decorator. I am a user of old version but a new release is being worked on that allows you to do exactly what you are asking for. Do a google search on sitemesh and you should find lots of examples.
In a nutshell sitemesh decoration: basic html + template = decorated page.

Filesystem-based web content

I plan to pull my Java web apps's content from a filesystem, for the sake of simplicity of editing. These files will be most probably only a text in a simple markup like JTexy or Markdown.
What I plan to implement is a tree-like structure keeping the content of the files.
It should be cached and eventually should handle authorization.
I am looking for a simple-to-use thing, not a full-blown CMS like OpenCMS, but if it provides a simple api to access the content and can keep it's dependencies small, the other stuff like thick client content editors is a bonus.
Perhaps something from this list: http://java-source.net/open-source/content-managment-systems
What would you recommend?
Thanks,
Ondra
Why not use a simple Apache webserver with a (f)cgi perl script to convert the markdown and a mod_proxy to cache the results.
Beeautiful in its simplicity!
If you do not intend to reinvent wheels then you should probably use a CMS.
As you write OpenCms is a full-blown CMS", but it also should be "simple-to-use" in your context.

Need a Java-based HTML prettifier to clean up Velocity-generated HTML

Web app I'm working on generates HTML using Velocity templates. Problem is that using whitespace in velocity templates and other formatting results in butt-ugly HTML (excessive whitespace, misalignment, etc.)
Looking for a nice (single jar packaging would be nice) Java-based HTML prettifier to run over the generated HTML right before we dump it to the servlet response to make the source nicer to look at.
Third party integrators would like to be able to glance at the HTML and know which templates are causing problems. The first step to this is having the HTML formatted nicely.
Thanks in advance for any guidance you can provide!
JTidy has a JTidyFilter. Just define it in web.xml and the respone HTML will be prettified.
JTidy could be what you're searching for.
I know it's not helping right now, but I think the ideal solution would be for Velocity in first place to support a "better whitespace generation and control" :).
If many users would request and vote such a feature, maybe the Velocity team would include it. Running jTidy or other parsers over the output all the time (e.g. for live requests) consumes quite a few resources, so I'm not sure if it's the best approach especially for dynamic content where caching of that cleaned output doesn't bring much.
There are many HTML parsers here: Open Source HTML Parsers in Java

Categories