You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by paul womack <pw...@papermule.co.uk> on 2008/05/09 17:58:02 UTC

formatting stricture differing from data structure?

I've succeeded (hearty thanks to all who have helped)
in making EPSF files.

Preview TIFFS are made using ghostscript (via imagemagick),
the fop postscript is turned into EPSF via some viciously
unsubtle edits using perl, and the tiff put onto the EPSF
with a suitable header via a little more perl.

Up until this point I've put little emphasis
on the sophistication of my stylesheet programming
(xslt) or formatting (fo).

My present data exactly matches (in structure)
my styling.

I can thus put one fo element on each data element,
and I'm good to go.

Even I can get the XSLT right for this...

A couple of questions have now occurred to me,
which a reading the Tidwell book
hasn't answered (easily).

If my feed xml (in DTD form) were:

<!ELEMENT data (heading, summary?, paragraph+)>

How could I (best) get a single fo element around
any summary (if present) and all the paragraphs?

Or in

<!ELEMENT poem (title,verse+)>

How could I get the first verse to be formatted
differently to the rest?

In both cases I want a fo element where
there isn't an exactly analogous element in
the feed xml.

I feel I'm missing something obvious;
I assume XSLT can easily handle this, given
that it can do cross referencing and sorting and stuff,
but I can't see how.

Can somebody point out the obvious to me?

   BugBear

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: formatting stricture differing from data structure?

Posted by Andreas Delmelle <an...@telenet.be>.
On May 9, 2008, at 17:58, paul womack wrote:

Hi

Just a note: for pure XSLT-related questions, you're always better  
off posting on Mulberry's XSLT list.

We try to make it a policy to point this out: this is a list for  
questions about using FOP.

No problem this time, but try to keep this in mind for the future.
We just want to avoid everyone posting their XSLT-questions here.  
Thanks!

Now, to answer your questions:

> A couple of questions have now occurred to me,
> which a reading the Tidwell book
> hasn't answered (easily).
>
> If my feed xml (in DTD form) were:
>
> <!ELEMENT data (heading, summary?, paragraph+)>
>
> How could I (best) get a single fo element around
> any summary (if present) and all the paragraphs?

To get one block that contains the summary and all paragraphs:

<xsl:template match="data">
   ...
   <fo:block>
     <xsl:apply-templates select="summary | paragraph" />
   </fo:block>
   ...
</xsl:template>

> Or in
>
> <!ELEMENT poem (title,verse+)>
>
> How could I get the first verse to be formatted
> differently to the rest?

One alternative would be:

<xsl:template match="verse">
   <xsl:choose>
     <xsl:when test="not(preceding-sibling::verse)">
       <fo:block xsl:use-attribute-sets="first-verse">
         <xsl:apply-templates />
       </fo:block>
     </xsl:when>
     <xsl:otherwise>
       <fo:block xsl:use-attribute-sets="other-verses">
         <xsl:apply-templates />
       </fo:block>
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>


HTH!

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org