Vassilis Koutavas wrote:
Sorry for the slow response. Connecting to the internet is not so easy
for me these days.
I'm also sorry for the slow response. I've been moving house so am only
just back online. Anyway...
So my problem is this: I'm trying to use Forrest to create a web site
to showcase info about the buildings built by some company. I have
created an XML file that contains the data of the buildings:
<buildings name="sorable-table-2">
<building
id="12102-00001"
location="Minies"
status="Completed">
<img src="12102-00001-thumb.jpg" alt="12102-00001"/>
</building>
..............
</buildings>
there are also other tags around the 'buildings' tag that are defined
in the 'document' dtd
I've created the appropriate DTD (as an extension of the document
DTD), and XSL according to the documentation. This way I produce one
html page that has a table of all the buildings.
Ideally I would like to do the following two things:
1) to create more than one pages with tables of all the buildigns with
different formatting (e.g. different grouping and sorting). I guess
this is not too difficult to do using the pipelines (where can I read
about how they work?).
Start at [1] - note the links to further docs.
I'm thinking of the following "workflow":
[raw XML containing only the 'buildings' tag] --> [XML 1 wrapping
the 'buildings' tag around some document tags like 'section',
'title',etc] ---> [HTML 1]
[raw XML containing only the 'buildings' tag] --> [XML 2 wrapping
the 'buildings' tag around *other* document tags] ---> [HTML 2]
You need to create an input plugin for your buildings format that will
create the required internal XDoc as you describe above. See [2] there
are plenty of examples of plugins like this in SVN, for example [3] is
about the closest we have to your use case (note this is 0.8-dev code,
but the basic principles are the same in 0.7, in fact this was
originally written against 0.5)
I see that you say you have already added this information to your
project, I recommend factoring this out into a plugin as this will
reduce your maintenance overhead when upgrading to newer versions of
Forrest.
In 0.7 the implementation of the different pipelines, for different
grouping/sorting can be done in two ways:
1) add a pipeline for each of the required page structures
2) add a generic pipeline that provides parameters to the XSL
transformation stage to control the sorting/grouping
Which you choose is dependent on your use case details and your need for
maintainability in the future (less pipelines is easier to maintain in
most cases).
2) I need to create one detailed page for each building. I would like
to create these pages from the same 'buildings' XML. This would mean
some more complicated workflows:
['buildings' XML] --> [XML 3.1 adding document tags] ---> [HTML 3.1]
['buildings' XML] --> [XML 3.2 adding document tags] ---> [HTML 3.2]
['buildings' XML] --> [XML 3.3 adding document tags] ---> [HTML 3.3]
................. (length depends on the number of buildings in the
'buildings' XML file).....
If it is easier, instead of one big 'buildings' XML file, I could
have one small XML file for each building, which would make the
creation of the detailed pages trivial, but I think it would
complicate the creation of the html pages that contain the tables of
buildings.
Either approach is possible, but both have their complications.
With one large file you would need to have an XSL to generate the list
of individual documents that need to be created. This will be used to
create part of the site.xml structure or an index page. It may be that
your first requirement above will result in such a list of required
pages. Your URLs for the detail pages will be something like
http://foo.com/building/12102-00001 where "12102-000012" is the value of
the building ID. This is passed as a param to the XSL and is used to
extract the relevant content and create the internal XDoc. Forrest does
the rest.
With lots of smaller files you would use the directory generator to
identify each of the files and then aggregate them together in order to
fulfill your first requirement. [4] gives an example of this. Since you
have one large file at present I'd go that way.
Either way the above should be part of the same input plugin.
Ross
[1] http://forrest.apache.org/docs_0_70/your-project.html#sitemap.xmap
[2] http://forrest.apache.org/docs_0_70/howto/howto-buildPlugin.html
[3]
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.glossary/
[4]
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.Resume/src/documentation/content/xdocs/