You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Victor Mote <vi...@outfitr.com> on 2003/03/12 19:10:09 UTC
custom formatting / css
Dear Forrest developers:
I am a sometime FOP developer, and have little (but growing) knowledge of
most of the other Apache projects. I have spent a fair amount of time trying
to find the answer the question below from the Forrest & Cocoon web sites,
but I am afraid this is probably a newbie question.
FOP has a document on its site which uses a custom DTD:
http://xml.apache.org/fop/compliance.html
About the time that we switched over to Forrest, I had written an XSLT
stylesheet which converted the source XML to HTML, embedding some "class"
attributes in the HTML <td> elements, and embedding some CSS code into the
document head for formatting based on those classes. Specifically, I am
trying to color-code cells in the table based on the classes. Someone (I
think Keiron Liddle) adapted the XSLT to convert to the document-v11 format
which is now used to generate our web site. At that time, we expected to
lose, and did lose, the color-coding, which I am now going to try to get
back.
COMMENTS
1. Interestingly, the "class" attributes survive all the way into the
published HTML. I would think that they might cause validation problems, as
they are not in the DTD.
QUESTIONS
1. Since document-v11 is a semantic-oriented DTD, with no formatting
information, is what I am trying to do here more-or-less violating the
spirit of what Forrest is intended to provide?
2. What is the best practices way of accomplishing this (ie. essentially
overriding the default Forrest formatting)?
3. Is there a mechanism for getting css code and/or references passed
through the document-v11 document? I have noted the thread with Peter West
about embedding ehtml documents, but I am under the impression that would be
for <body> contents. IIUC, the custom DTD has nothing to do with this, but
this is rather a general question that would apply to any document-v11
document.
4. Is this all documented somewhere & I just missed it?
TIA for your help. It has been fun to see Forrest evolve into a very useful
product. Thanks for all of your efforts.
Victor Mote (mailto:vic@outfitr.com)
2025 Eddington Way
Colorado Springs, Colorado 80916
Voice +1 (719) 622-0650
Fax +1 (720) 293-0044
RE: custom formatting / css
Posted by Victor Mote <vi...@outfitr.com>.
Jeff Turner wrote:
> Cocoon goes through each page (starting with index.html), and after
> rendering it, extracts all the links to other pages, and renders them.
> If no other pages reference compliance.pdf, it won't be rendered.
>
> I suggest you add a <a href="compliance.pdf"> link to the output of your
> compliance2html.xsl stylesheet.
>
> Btw, you can debug what links a page has by typing 'forrest run', and
> then requesting http://localhost:8888/compliance.html?cocoon-view=links
OK -- I had thought I would get the document built first, then add the link
after that worked. I have that working now.
My forrest log indicates that either compliance.html or the document before
it is generating an NPE from Xalan, and this is probably caused by the
little table that I added to get the pdf icon next to the title, mimicking
the output of some document2fo pdfs. I am unable to duplicate this outside
of Forrest, even using the Xalan that comes with Forrest. It doesn't /seem/
to affect anything -- the output appears to all be there. I'm not going to
ask you to find the problem, but if you happen to recognize it, please let
me know.
The pdf itself is mangled & unusable, but that is no doubt because the
version of FOP forrest (or at least forrestbot) is using is not current.
When I run it manually with current FOP CVS, I do get usable output (it is
not pretty, but that is a FOP issue). This is not very important, so please
don't interpret this as a request to change anything.
Thanks again for your help getting the FOP site up and running.
Victor Mote
Re: custom formatting / css
Posted by Jeff Turner <je...@apache.org>.
On Wed, Mar 26, 2003 at 07:53:52PM -0700, Victor Mote wrote:
> Jeff Turner wrote: (Sent: Tuesday, March 18, 2003 7:33 PM)
>
> > Should be pretty simple to create a compliance.pdf pipeline, if you
> > modify Forrest's document2fo.xsl to create a compliance2fo.xsl:
> >
> > <map:match pattern="compliance.pdf">
> > <map:generate type="file-nolabel" src="content/xdocs/compliance.xml" />
> > <map:transform src="resources/stylesheets/compliance2fo.xsl"
> > label="content" />
> > <map:serialize type="fo2pdf" />
> > </map:match>
> >
> > That needs to be inserted before the generic '*.pdf' matcher.
>
> OK, I have had the compliance2fo.xsl for some time, and have the <map:match>
> as you have noted above. On my local machine, I have it much higher in the
> pipeline than it is in the FOP CVS repository, but neither produces a
> compliance.pdf file. I have gotten myself slightly more educated on
> Cocoon -- I was not sure whether Cocoon was pushing content or responding to
> requests. I (think I) now understand that Cocoon is responding to requests.
> So -- is there any chance that Forrest is not sending a request for
> compliance.pdf to Cocoon?
Oh, yes..
Cocoon goes through each page (starting with index.html), and after
rendering it, extracts all the links to other pages, and renders them.
If no other pages reference compliance.pdf, it won't be rendered.
I suggest you add a <a href="compliance.pdf"> link to the output of your
compliance2html.xsl stylesheet.
Btw, you can debug what links a page has by typing 'forrest run', and
then requesting http://localhost:8888/compliance.html?cocoon-view=links
--Jeff
> Otherwise, would I not see an error in the log? Right now, there is no
> mention of compliance.pdf in the log at all.
>
> Victor Mote
>
RE: custom formatting / css
Posted by Victor Mote <vi...@outfitr.com>.
Jeff Turner wrote: (Sent: Tuesday, March 18, 2003 7:33 PM)
> Should be pretty simple to create a compliance.pdf pipeline, if you
> modify Forrest's document2fo.xsl to create a compliance2fo.xsl:
>
> <map:match pattern="compliance.pdf">
> <map:generate type="file-nolabel" src="content/xdocs/compliance.xml" />
> <map:transform src="resources/stylesheets/compliance2fo.xsl"
> label="content" />
> <map:serialize type="fo2pdf" />
> </map:match>
>
> That needs to be inserted before the generic '*.pdf' matcher.
OK, I have had the compliance2fo.xsl for some time, and have the <map:match>
as you have noted above. On my local machine, I have it much higher in the
pipeline than it is in the FOP CVS repository, but neither produces a
compliance.pdf file. I have gotten myself slightly more educated on
Cocoon -- I was not sure whether Cocoon was pushing content or responding to
requests. I (think I) now understand that Cocoon is responding to requests.
So -- is there any chance that Forrest is not sending a request for
compliance.pdf to Cocoon? Otherwise, would I not see an error in the log?
Right now, there is no mention of compliance.pdf in the log at all.
Victor Mote
Re: custom formatting / css
Posted by Jeff Turner <je...@apache.org>.
On Tue, Mar 18, 2003 at 09:20:19AM -0700, Victor Mote wrote:
> Victor Mote wrote:
> > Jeff Turner wrote:
> > > So to get a custom HTML format, you would simply delete everything from
> > > the transform down, and replace it with:
> > >
> > > <map:transform src="resources/stylesheets/compliance2html.xsl"/>
> > > <map:serialize type="xml"/>
> > >
> > > Note that compliance2html.xsl has to have a root tag of <div
> > > class="content">. This allows the resultant HTML to be merged with the
> > > menu and tabs. If it doesn't work, try 'forrest run', and then request
> > > http://localhost:8888/body-compliance.xml, and see what's actually being
> > > produced.
> >
> > Thanks -- I'll work on that here shortly. And your answer also gives me a
> > piece of the puzzle I didn't understand before :-)
>
> OK, I got that done, and the page looks great (or at least as intended)! The
> only remaining issue is that the PDF icon is gone & the pdf does not appear
> to be generated during the build. I should be able to track that down.
Well, by bypassing the intermediate format, you've assumed responsibility
for rendering the end formats (HTML, PDF). In particular, the
compliance2html.xsl stylesheet now has to insert the link to the PDF,
since the document2html.xsl stylesheet (which normally does it) isn't
invoked.
Should be pretty simple to create a compliance.pdf pipeline, if you
modify Forrest's document2fo.xsl to create a compliance2fo.xsl:
<map:match pattern="compliance.pdf">
<map:generate type="file-nolabel" src="content/xdocs/compliance.xml" />
<map:transform src="resources/stylesheets/compliance2fo.xsl" label="content" />
<map:serialize type="fo2pdf" />
</map:match>
That needs to be inserted before the generic '*.pdf' matcher.
--Jeff
PS: testing sitemap edits with command-line rendering is exceedingly
painful, so if you're not already, you might want to do 'forrest run',
and then play with the sitemap in build/webapp/sitemap.xmap, and view on
http://localhost:8888.
> Thanks again very much.
>
> Victor Mote
>
RE: custom formatting / css
Posted by Victor Mote <vi...@outfitr.com>.
Victor Mote wrote:
> Jeff Turner wrote:
> > So to get a custom HTML format, you would simply delete everything from
> > the transform down, and replace it with:
> >
> > <map:transform src="resources/stylesheets/compliance2html.xsl"/>
> > <map:serialize type="xml"/>
> >
> > Note that compliance2html.xsl has to have a root tag of <div
> > class="content">. This allows the resultant HTML to be merged with the
> > menu and tabs. If it doesn't work, try 'forrest run', and then request
> > http://localhost:8888/body-compliance.xml, and see what's actually being
> > produced.
>
> Thanks -- I'll work on that here shortly. And your answer also gives me a
> piece of the puzzle I didn't understand before :-)
OK, I got that done, and the page looks great (or at least as intended)! The
only remaining issue is that the PDF icon is gone & the pdf does not appear
to be generated during the build. I should be able to track that down.
Thanks again very much.
Victor Mote
RE: custom formatting / css
Posted by Victor Mote <vi...@outfitr.com>.
Jeff Turner wrote:
> Sorry for the slow reply! Started reading, got distracted, then forgot
> to pick it up..
No apology needed.
...
> So to get a custom HTML format, you would simply delete everything from
> the transform down, and replace it with:
>
> <map:transform src="resources/stylesheets/compliance2html.xsl"/>
> <map:serialize type="xml"/>
>
> Note that compliance2html.xsl has to have a root tag of <div
> class="content">. This allows the resultant HTML to be merged with the
> menu and tabs. If it doesn't work, try 'forrest run', and then request
> http://localhost:8888/body-compliance.xml, and see what's actually being
> produced.
Thanks -- I'll work on that here shortly. And your answer also gives me a
piece of the puzzle I didn't understand before :-)
> > 3. Is there a mechanism for getting css code and/or references passed
> > through the document-v11 document? I have noted the thread with
> Peter West
> > about embedding ehtml documents, but I am under the impression
> that would be
> > for <body> contents. IIUC, the custom DTD has nothing to do
> with this, but
> > this is rather a general question that would apply to any document-v11
> > document.
>
> There isn't yet. Perhaps there should be a 'class' attribute allowed,
> with the ability to define an add-on CSS stylesheets.
The beauty of that approach is that the CSS could be used only to override
things in the standard skin. Otherwise, what I will end up with is either 1)
a page that doesn't look like the others, or 2) a fair amount of formatting
work that will have to be redone if the skin changes. I guess a third
alternative is that if the skin uses CSS to do most of its work, then I
could pull that in to my document -- I haven't looked at this possibility,
but I will.
Thanks again.
Victor Mote
Re: custom formatting / css
Posted by Jeff Turner <je...@apache.org>.
Hi Victor,
Sorry for the slow reply! Started reading, got distracted, then forgot
to pick it up..
On Wed, Mar 12, 2003 at 11:10:09AM -0700, Victor Mote wrote:
> Dear Forrest developers:
>
> I am a sometime FOP developer, and have little (but growing) knowledge of
> most of the other Apache projects. I have spent a fair amount of time trying
> to find the answer the question below from the Forrest & Cocoon web sites,
> but I am afraid this is probably a newbie question.
>
> FOP has a document on its site which uses a custom DTD:
> http://xml.apache.org/fop/compliance.html
>
> About the time that we switched over to Forrest, I had written an XSLT
> stylesheet which converted the source XML to HTML, embedding some "class"
> attributes in the HTML <td> elements, and embedding some CSS code into the
> document head for formatting based on those classes. Specifically, I am
> trying to color-code cells in the table based on the classes. Someone (I
> think Keiron Liddle) adapted the XSLT to convert to the document-v11 format
> which is now used to generate our web site. At that time, we expected to
> lose, and did lose, the color-coding, which I am now going to try to get
> back.
>
> COMMENTS
> 1. Interestingly, the "class" attributes survive all the way into the
> published HTML. I would think that they might cause validation problems, as
> they are not in the DTD.
>
> QUESTIONS
> 1. Since document-v11 is a semantic-oriented DTD, with no formatting
> information, is what I am trying to do here more-or-less violating the
> spirit of what Forrest is intended to provide?
The intermediate doc-v11 format is mostly there so we can have just one
document2fo.xsl stylesheet, not {format}2fo.xsl for every possible
<format>. In many cases (like yours), doc-v11 isn't expressive enough,
and one has to write custom {format}2{html,fo}.xsl stylesheets.
> 2. What is the best practices way of accomplishing this (ie. essentially
> overriding the default Forrest formatting)?
Here is what Keiron added:
<map:match pattern="body-compliance.xml">
<map:generate type="file-nolabel" src="content/xdocs/compliance.xml"/>
<map:transform src="resources/stylesheets/compliance2document.xsl" label="content"/>
<map:call resource="skinit">
<map:parameter name="type" value="document2html"/>
<map:parameter name="path" value="compliance"/>
</map:call>
</map:match>
This pipeline creates the "body" (distinct from "menu" and "tabs") of the
compliance.html page. It applies compliance2document.xsl, and then the
'skinit' pipeline snippet (defined in map:resources), which applies
document2html.xsl.
So to get a custom HTML format, you would simply delete everything from
the transform down, and replace it with:
<map:transform src="resources/stylesheets/compliance2html.xsl"/>
<map:serialize type="xml"/>
Note that compliance2html.xsl has to have a root tag of <div
class="content">. This allows the resultant HTML to be merged with the
menu and tabs. If it doesn't work, try 'forrest run', and then request
http://localhost:8888/body-compliance.xml, and see what's actually being
produced.
> 3. Is there a mechanism for getting css code and/or references passed
> through the document-v11 document? I have noted the thread with Peter West
> about embedding ehtml documents, but I am under the impression that would be
> for <body> contents. IIUC, the custom DTD has nothing to do with this, but
> this is rather a general question that would apply to any document-v11
> document.
There isn't yet. Perhaps there should be a 'class' attribute allowed,
with the ability to define an add-on CSS stylesheets.
> 4. Is this all documented somewhere & I just missed it?
Almost ;) Adding compliance.html would fall under:
http://xml.apache.org/forrest/your-project.html#adding_new_content_type
> TIA for your help. It has been fun to see Forrest evolve into a very useful
> product. Thanks for all of your efforts.
Thanks :)
--Jeff
> Victor Mote (mailto:vic@outfitr.com)
> 2025 Eddington Way
> Colorado Springs, Colorado 80916
> Voice +1 (719) 622-0650
> Fax +1 (720) 293-0044
>