Specifying styles or attribute sets in an FO document

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Specifying styles or attribute sets in an FO document

Richard M
Other than using XSLT transformations, is there a way of specifing
common characteristics for table cells and other formatting elements in
an FO document? Somethink like CSS I guess (inline or otherwise)

My data model is currently Java Beans and is being processed by JSP/JSTL
pretty well. I hate to introduce XSLT transformation on top of this just
to reduce the verbosity of my FO document.

Thanks for any ideas - Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Pascal Sancho
Hi,
For this purpose, I use xsl:attributes-set elements in a separate xslt file, referenced through a xsl:include element.
I just need to add a xsl:use-attribute-sets when needed (do not forget the xsl namespace when you use this attribute in a non-xsl element, such as a fo:block)
This works fine.

Pascal SANCHO

> -----Message d'origine-----
> De : Richard Mixon (qwest) [mailto:[hidden email]]
> Envoyé : lundi 9 mai 2005 04:44
>
> Other than using XSLT transformations, is there a way of
> specifing common characteristics for table cells and other
> formatting elements in an FO document? Somethink like CSS I
> guess (inline or otherwise)
>
> My data model is currently Java Beans and is being processed
> by JSP/JSTL pretty well. I hate to introduce XSLT
> transformation on top of this just to reduce the verbosity of
> my FO document.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Richard M
Pascal Sancho wrote:
> Hi,
> For this purpose, I use xsl:attributes-set elements in a separate
> xslt file, referenced through a xsl:include element.
> I just need to add a xsl:use-attribute-sets when needed (do not
> forget the xsl namespace when you use this attribute in a non-xsl
> element, such as a fo:block) This works fine.  
>
> Pascal SANCHO

Pascal,
That sounds like it would do the trick. Can you point me to an example
that shows how to do this somewhere?
Thank you - Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

JBryant
In reply to this post by Richard M
> Can you point me to an example
> that shows how to do this somewhere?

http://www.bryantcs.com/fop

SpecToPDF.xsl uses xsl:include (right at the top of the file) to include
the styles specified in pdfstyles.xsl.

HTH

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Pascal Sancho
In reply to this post by Richard M
Hi,

Snippets are in fine.
Hope this will help you

 
Pascal SANCHO

 

> -----Message d'origine-----
> De : Richard Mixon (qwest) [mailto:[hidden email]]
> Envoyé : lundi 9 mai 2005 14:45
> À : [hidden email]
> Objet : RE: Specifying styles or attribute sets in an FO document
>
> Pascal Sancho wrote:
> > Hi,
> > For this purpose, I use xsl:attributes-set elements in a
> separate xslt
> > file, referenced through a xsl:include element.
> > I just need to add a xsl:use-attribute-sets when needed (do
> not forget
> > the xsl namespace when you use this attribute in a non-xsl element,
> > such as a fo:block) This works fine.
> >
> > Pascal SANCHO
>
> Pascal,
> That sounds like it would do the trick. Can you point me to
> an example that shows how to do this somewhere?
> Thank you - Richard
>

Here is an example of a couple of XSL:
 - the 1st one is called by your engine;
 - the 2nd one is called by the 1st xsl.

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:include href="styles-fo.xsl"/>

<!-- root element ====================================================== -->
<xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
                        <fo:layout-master-set>
                                <xsl:call-template name="masters"/>
                        </fo:layout-master-set>
                <fo:page-sequence master-reference="default">
                        <!-- you can make some call-template here to fill-in static regions -->

                        <fo:flow flow-name="xsl-region-body">
                                <fo:block xsl:use-attribute-sets="simple_block">check</fo:block>
                        </fo:flow>
                </fo:page-sequence>
        </fo:root>
</xsl:template>

<!-- masters ============================================================= -->
<xsl:template name="masters">
        <!-- all attributes can be defined in other styles-fo.xsl , using attribute-set-->

        <fo:simple-page-master master-name="default" xsl:use-attribute-sets="master">
                <fo:region-body xsl:use-attribute-sets="masterBody"/>
                <fo:region-before xsl:use-attribute-sets="masterBefore"/>
                <fo:region-after xsl:use-attribute-sets="masterAfter"/>
                <fo:region-start xsl:use-attribute-sets="masterStart"/>
                <fo:region-end xsl:use-attribute-sets="masterEnd"/>
        </fo:simple-page-master>
</xsl:template>

</xsl:stylesheet>


<!-- here follows the xsl named "styles-fo.xsl"

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<!-- masters ============================================================= -->
<xsl:template name="masters">
        <!-- all attributes can be defined in other styles-fo.xsl , using attribute-set-->

        <fo:simple-page-master master-name="default" xsl:use-attribute-sets="master">
                <fo:region-body xsl:use-attribute-sets="masterBody"/>
                <fo:region-before xsl:use-attribute-sets="masterBefore"/>
                <fo:region-after xsl:use-attribute-sets="masterAfter"/>
                <fo:region-start xsl:use-attribute-sets="masterStart"/>
                <fo:region-end xsl:use-attribute-sets="masterEnd"/>
        </fo:simple-page-master>
</xsl:template>

<!-- page master ========================================================= -->
<xsl:attribute-set name="master">
        <xsl:attribute name="page-height">297mm</xsl:attribute>
        <xsl:attribute name="page-width">210mm</xsl:attribute>
        <xsl:attribute name="margin-top">10mm</xsl:attribute>
        <xsl:attribute name="margin-bottom">10mm</xsl:attribute>
        <xsl:attribute name="margin-left">10mm</xsl:attribute>
        <xsl:attribute name="margin-right">10mm</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="masterBody">
        <xsl:attribute name="margin-top">65mm</xsl:attribute>
        <xsl:attribute name="margin-bottom">20mm</xsl:attribute>
        <xsl:attribute name="margin-left">10mm</xsl:attribute>
        <xsl:attribute name="margin-right">0mm</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="masterBefore">
        <xsl:attribute name="extent">65mm</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="masterAfter">
        <xsl:attribute name="extent">15mm</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="masterStart">
        <xsl:attribute name="extent">0mm</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="masterEnd">
        <xsl:attribute name="extent">0mm</xsl:attribute>
</xsl:attribute-set>

<!-- boxes ============================================================== -->
<xsl:attribute-set name="simple_block_1">
        <!-- note that you can add an use-attribute-sets attribute to this attribute-set -->
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">sans-serif</xsl:attribute>
        <xsl:attribute name="space-after">1.5mm</xsl:attribute>
</xsl:attribute-set>

<xsl:template name="simple_block_2">
        <!-- this is an alternative to attribute-set, when formatting depends on context -->
        <xsl:attribute name="font-size">11pt</xsl:attribute>
        <xsl:attribute name="font-family">sans-serif</xsl:attribute>
        <xsl:if test="following-sibling::*">
                <xsl:attribute name="space-after">1.5mm</xsl:attribute>
        </xsl:if>
</xsl:template>

</xsl:stylesheet>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Richard M
In reply to this post by JBryant
[hidden email] wrote:
>> Can you point me to an example
>> that shows how to do this somewhere?
>
> http://www.bryantcs.com/fop
>
> SpecToPDF.xsl uses xsl:include (right at the top of the file) to
> include the styles specified in pdfstyles.xsl.

Jay,
Thanks for the example - however its not quite what I am trying to do
(which may not be possible).

I am currently processing a single FO file (say report1.fo) which is
generated by servlet/jsp code. My Java servlet is setup to expect this
one FO file. What I would like is a way to specify the attribute-set
inline at the top of the .fo file and then reference them further down
in fo layout statements.

Granted, the code change to my servlet to handle just an xsl file is not
that great - but the ripple effect to the application is a bit more than
I would like to endure right now.

Maybe my solution (since my application is JSP/JSTL oriented and not
XSL/XSLT based) is to juse use some JSP scripting or custom tags to do
this. Just figured there might be a more "standard" solution.

Thank you - Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Richard M
In reply to this post by Pascal Sancho
Pascal,

Thank you once again for the example. It’s a bit different (as I just
posted back to Jay) than the solution I was looking for in that it
involves processing an XSL file instead of just a straight FO file with
either embedded or included XSL attribute sets.

Its starting to sound like the "standard" way for doing styles in FO is
to use XSLT (sort of makes sense). As my other post says I just was
hoping not to reconfigure my FO servlet as it handles a number of tasks
the way it is currently coded.

Thank you - Richard

Pascal Sancho wrote:

> Hi,
>
> Snippets are in fine.
> Hope this will help you
>
>
> Pascal SANCHO
>
>
>
>> -----Message d'origine-----
>> De : Richard Mixon (qwest) [mailto:[hidden email]] Envoyé : lundi
>> 9 mai 2005 14:45 À : [hidden email] Objet : RE:
>> Specifying styles or attribute sets in an FO document
>>
>> Pascal Sancho wrote:
>>> Hi,
>>> For this purpose, I use xsl:attributes-set elements in a separate
>>> xslt file, referenced through a xsl:include element.
>>> I just need to add a xsl:use-attribute-sets when needed (do not
>>> forget the xsl namespace when you use this attribute in a non-xsl
>>> element, such as a fo:block) This works fine.
>>>
>>> Pascal SANCHO
>>
>> Pascal,
>> That sounds like it would do the trick. Can you point me to an
>> example that shows how to do this somewhere?
>> Thank you - Richard
>>
>
> Here is an example of a couple of XSL:
>  - the 1st one is called by your engine;
>  - the 2nd one is called by the 1st xsl.
>
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format">  
>
> <xsl:include href="styles-fo.xsl"/>
>
> <!-- root element
> ====================================================== -->
> <xsl:template match="/"> <fo:root
>
xmlns:fo="http://www.w3.org/1999/XSL/Format">
> <fo:layout-master-set> <xsl:call-template
name="masters"/>
> </fo:layout-master-set> <fo:page-sequence
> master-reference="default"> <!-- you can make
some call-template
> here to fill-in static regions -->
>
> <fo:flow flow-name="xsl-region-body">
> <fo:block
xsl:use-attribute-sets="simple_block">check</fo:block>
> </fo:flow>
> </fo:page-sequence>
> </fo:root>
> </xsl:template>
>
> <!-- masters
> =============================================================
-->

> <xsl:template name="masters"> <!-- all attributes can be defined in
> other styles-fo.xsl , using attribute-set-->  
>
> <fo:simple-page-master master-name="default"
> xsl:use-attribute-sets="master"> <fo:region-body
> xsl:use-attribute-sets="masterBody"/> <fo:region-before
> xsl:use-attribute-sets="masterBefore"/> <fo:region-after
> xsl:use-attribute-sets="masterAfter"/> <fo:region-start
> xsl:use-attribute-sets="masterStart"/> <fo:region-end
> xsl:use-attribute-sets="masterEnd"/> </fo:simple-page-master>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> <!-- here follows the xsl named "styles-fo.xsl"
>
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format">  
>
> <!-- masters
> =============================================================
-->

> <xsl:template name="masters"> <!-- all attributes can be defined in
> other styles-fo.xsl , using attribute-set-->  
>
> <fo:simple-page-master master-name="default"
> xsl:use-attribute-sets="master"> <fo:region-body
> xsl:use-attribute-sets="masterBody"/> <fo:region-before
> xsl:use-attribute-sets="masterBefore"/> <fo:region-after
> xsl:use-attribute-sets="masterAfter"/> <fo:region-start
> xsl:use-attribute-sets="masterStart"/> <fo:region-end
> xsl:use-attribute-sets="masterEnd"/> </fo:simple-page-master>
> </xsl:template>
>
> <!-- page master
> ========================================================= -->
> <xsl:attribute-set name="master"> <xsl:attribute
> name="page-height">297mm</xsl:attribute> <xsl:attribute
> name="page-width">210mm</xsl:attribute> <xsl:attribute
> name="margin-top">10mm</xsl:attribute> <xsl:attribute
> name="margin-bottom">10mm</xsl:attribute> <xsl:attribute
> name="margin-left">10mm</xsl:attribute> <xsl:attribute
> name="margin-right">10mm</xsl:attribute> </xsl:attribute-set>
>
> <xsl:attribute-set name="masterBody">
> <xsl:attribute name="margin-top">65mm</xsl:attribute>
> <xsl:attribute name="margin-bottom">20mm</xsl:attribute>
> <xsl:attribute name="margin-left">10mm</xsl:attribute>
> <xsl:attribute name="margin-right">0mm</xsl:attribute>
> </xsl:attribute-set>
>
> <xsl:attribute-set name="masterBefore">
> <xsl:attribute name="extent">65mm</xsl:attribute>
> </xsl:attribute-set>
>
> <xsl:attribute-set name="masterAfter">
> <xsl:attribute name="extent">15mm</xsl:attribute>
> </xsl:attribute-set>
>
> <xsl:attribute-set name="masterStart">
> <xsl:attribute name="extent">0mm</xsl:attribute>
</xsl:attribute-set>
>
> <xsl:attribute-set name="masterEnd">
> <xsl:attribute name="extent">0mm</xsl:attribute>
</xsl:attribute-set>
>
> <!-- boxes
> ==============================================================
-->
> <xsl:attribute-set name="simple_block_1"> <!-- note that you can
add
> an use-attribute-sets attribute to this attribute-set -->
> <xsl:attribute name="font-size">11pt</xsl:attribute>
<xsl:attribute

> name="font-family">sans-serif</xsl:attribute> <xsl:attribute
> name="space-after">1.5mm</xsl:attribute> </xsl:attribute-set>
>
> <xsl:template name="simple_block_2">
> <!-- this is an alternative to attribute-set, when formatting
> depends on context --> <xsl:attribute
> name="font-size">11pt</xsl:attribute> <xsl:attribute
> name="font-family">sans-serif</xsl:attribute> <xsl:if
> test="following-sibling::*"> <xsl:attribute
> name="space-after">1.5mm</xsl:attribute> </xsl:if>
> </xsl:template>
>
> </xsl:stylesheet>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

JBryant
In reply to this post by Richard M
Hi, Richard,

> What I would like is a way to specify the
> attribute-set inline at the top of the .fo
> file and then reference them further down
> in fo layout statements.

That won't work in an FO file because FO doesn't know anything about
transformation. You are right in thinking that you'll have to get the
information through one of your Java-based steps in the process.

I think the "standard" solution is to use XSLT to produce the FO file,
which you indicate you are not doing. Given what little I understand of
your processing model, I would apply the styles in the JSP layer. That
would let me follow the general rule of applying style as late as possible
so that I can produce different output formats with as few "upstream"
changes to the process as possible.

FWIW

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Richard M
[hidden email] wrote:

> Hi, Richard,
>
>> What I would like is a way to specify the attribute-set inline at the
>> top of the .fo file and then reference them further down in fo layout
>> statements.
>
> That won't work in an FO file because FO doesn't know anything about
> transformation. You are right in thinking that you'll have to get the
> information through one of your Java-based steps in the process.  
>
> I think the "standard" solution is to use XSLT to produce the FO
> file, which you indicate you are not doing. Given what little I
> understand of your processing model, I would apply the styles in the
> JSP layer. That would let me follow the general rule of applying
> style as late as possible so that I can produce different output
> formats with as few "upstream" changes to the process as possible.    
>
> FWIW

Jay, thanks. I just tried that and its working like a charm. I've just
defined my styles as a bunch of JSP scripting variables and reference
them in my FO markup. Since I'm using JSP 2.0, I don't need to use any
ugly embeded tags (i.e. "tags within tags"). In case the post might help
someone else in the future, here's a snipped of what I am doing.

<BEGIN FO file>
 ...
 <c:set var="fo_font_std" value='font-family="sans-serif"'/>
 <c:set var="fo_border_light" value='border-collapse="separate"
border-color="black" border-width="0.5pt" border-style="solid"'/>
 <c:set var="fo_border_heavy" value='border-collapse="separate"
border-color="black" border-width="1pt" border-style="solid"'/>
 <c:set var="fo_cell_detail" value='${fo_font_std} font-size="10pt"
text-align="right"'/>
 <c:set var="fo_cell_newSet" value='${fo_font_std} font-size="12pt"'/>

 ... Then later on I can refer to the above styles using JSP 2.0 syntax
of ${variable_name} as follows:
  <fo:table-row>
    <fo:table-cell ${fo_border_light}>
      <fo:block ${fo_cell_detail}>
        Cell text
      </fo:block>
    </fo:table-cell>

Thanks to all that have helped - Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Specifying styles or attribute sets in an FO document

J.Pietschmann
In reply to this post by Pascal Sancho
Pascal Sancho wrote:
> For this purpose, I use xsl:attributes-set elements in a separate
> xslt file, referenced through a xsl:include element. I just need to
> add a xsl:use-attribute-sets when needed (do not forget the xsl
> namespace when you use this attribute in a non-xsl element, such as a
> fo:block) This works fine.

This implies running an XSL transformation, which the original poster
wants to avoid.

J.Pietschmann

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Specifying styles or attribute sets in an FO document

gmazza
In reply to this post by Richard M
Richard Mixon (qwest) schrieb:

>Other than using XSLT transformations, is there a way of specifing
>common characteristics for table cells and other formatting elements in
>an FO document? Somethink like CSS I guess (inline or otherwise)
>
>My data model is currently Java Beans and is being processed by JSP/JSTL
>pretty well. I hate to introduce XSLT transformation on top of this just
>to reduce the verbosity of my FO document.
>
>Thanks for any ideas - Richard
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>  
>
Richard,

You would be missing out on perhaps the most enjoyable part of XSLT/XSL
design:  factoring out common formatting to be shared by several XSL FO
files.  Please have a look at this article:  
http://xml.sys-con.com/read/40601.htm.

Glen


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Specifying styles or attribute sets in an FO document

Richard M
Glen Mazza wrote:
> Richard Mixon (qwest) schrieb:
> <SNIP>
> Richard,
>
> You would be missing out on perhaps the most enjoyable part of
> XSLT/XSL
> design:  factoring out common formatting to be shared by several XSL
> FO files.  Please have a look at this article:
> http://xml.sys-con.com/read/40601.htm.

Glen,
Thanks for taking the time to point out this article. I'm reading it as
we speak (actually right after this note:).

I'm peripherally aware of how powerful XSL and XSLT is. However most of
our data model is already exposed as Java Beans. I had concerns that
introducing XSL and the ensuing transform would end up being a good bit
more resource-intensive than just generating straight XSL-FO statements
... But maybe not.

Thanks again - Richard


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]