Re: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-10 Thread Clóvis Wichoski


Hi,

Can't you use multiple page-sequences instead of just creating one sequence
'interrupted' by the 'ctrlPage' template?
 

but How?
this template is more difficult since it is used in with a more 
complicated XML like groupproduct/.../group..., the way that I 
sent is for brevety to discover because ctrlPage don't work, for groups 
I need print a header, followed by products, etc..., in original XSL i 
use xalan extensions to count how many lines I used PDF.

A few remarks to help you on your way:
1. I can't seem to find the reason why you are placing the whole
fo:static-content  into a separate template, since it is ... well, static
and it doesn't rely on the elements in the XML (unless something is
missing).
 

because, I reduced the code for brevety, then the static-content is for 
groups case. sorry

2. In the ctrlPage template, you are testing for a position(): you could
also use XPath to select these, like
xsl:apply-templates select=product[(position() mod 3) = 0]

Then inside the product template, use

xsl:for-each select=preceding::product[position()  3] /

to grab the two preceding product nodes.
 

but for-each select don't put Xalan in DOM process? consumes more 
memory? however I can't use position because the original XML is more 
complex. (I use xalan extensions to control this). like this xsl:if 
test=counter:read('ctLine') mod 3/xsl:if

3. Check our http://xml.apache.org/fop/resources.html page, among the books
and articles, there's a link to Dave Pawson's XSLT FAQ. Over there, you'll
find a lot of useful stuff (amongst others on grouping which I think you'll
find particularly helpful), so I'll bet you can work out a redesign which
affects only the XSL itself and leaves the other files alone.
If you really can't get any further, try posting your problem on Mulberry's
XSLT list. Warning: it's a quite high-traffic list, but the upside is that
the tips are 'highly-usable' ;)
Hope this helps!

Cheers,

Andreas

 

Thanks for tips

Clovis



multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Clóvis Wichoski
Hi FOP DevTeam,

I developed a way to generate multiple page-sequence on XSL without to 
change my XML, but the XML-XSL-PDF don't work, to make this work, first 
I need to generate the .fo file, then transform this to PDF.

if run:

fop.sh -xml sample.xml -xsl multiplePageSequence.xsl -pdf sample.pdf

I get follow output:

[INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser
[INFO] FOP 0.20.5
[INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser
[INFO] building formatting object tree
[INFO] setting up fonts
[ERROR] org.apache.fop.apps.FOPException: flow must be child of 
page-sequence, not fo:flow

but if I first generate the .fo file with:

xalan.sh -IN sample.xml -XSL multiplePageSequence.xsl -OUT sample.fo

then generate the .pdf file from .fo file with:

fop.sh -fo sample.fo -pdf sample.pdf

I get the follow output:

[INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser
[INFO] FOP 0.20.5
[INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser
[INFO] building formatting object tree
[INFO] setting up fonts
[INFO] [1]
[INFO] [2]
[INFO] [3]
[INFO] [4]
[INFO] Parsing of document complete, stopping renderer
The part of XSL that cause on the fly transformation to catch the ERROR is:

xsl:template name=ctrlPage 
   xsl:if test=(position() mod 3) = 0
   xsl:text 
disable-output-escaping=yes![CDATA[/fo:flow/fo:page-sequencefo:page-sequence 
master-reference=A4 language=pt country=br]]/xsl:text
   xsl:call-template name=header/
   xsl:text disable-output-escaping=yes![CDATA[fo:flow 
flow-name=xsl-region-body]]/xsl:text
   /xsl:if
/xsl:template

to close and open fo:flow and fo:page-sequence for

xsl:template match=data
   fo:page-sequence master-reference=A4 language=pt country=br
   xsl:call-template name=header/
   fo:flow flow-name=xsl-region-body
   xsl:apply-templates /
   /fo:flow
   /fo:page-sequence
   /xsl:template
I can't understand because on the fly don't woks and from .fo file 
generated from xml+xsl transformation work, maybe a bug of FOP, or I 
can't generate XML elements using CDATA from this form.

I post this in dev list because I think that this is a feature or a bug 
on FOP then I attached the XSL and XML files that the team can test this 
issue, and the code is better to read than my bad English ;)

Thanks for any help or tip

Clovis
?xml version=1.0 encoding=ISO-8859-1?
xsl:stylesheet version=1.0
xmlns:fo=http://www.w3.org/1999/XSL/Format;
xmlns:xsl=http://www.w3.org/1999/XSL/Transform;

xsl:output method=xml/

xsl:template match=/
fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format;
fo:layout-master-set
fo:simple-page-master master-name=A4 page-width=297mm  page-height=210mm margin-top=5mm  margin-bottom=5mm margin-left=3mm margin-right=5mm
fo:region-before extent=20.8mm/
fo:region-body margin-top=21.8mm margin-bottom=0in/
fo:region-after extent=0in/
fo:region-start extent=0in margin-top=0mm  margin-bottom=0mm margin-left=0mm margin-right=0mm/
fo:region-end extent=0in margin-top=0mm  margin-bottom=0mm margin-left=0mm margin-right=0mm/
/fo:simple-page-master
   /fo:layout-master-set
   xsl:apply-templates /
/fo:root
/xsl:template

xsl:template match=info/xsl:template

xsl:template match=data
fo:page-sequence master-reference=A4 language=pt country=br
xsl:call-template name=header/
fo:flow flow-name=xsl-region-body
xsl:apply-templates /
/fo:flow
/fo:page-sequence
/xsl:template
  
xsl:template match=product
xsl:call-template name=detail /
/xsl:template

!-- Header For Pages --
xsl:template name=header
fo:static-content flow-name=xsl-region-before
fo:table table-layout=fixed
fo:table-column column-width=40mm/
fo:table-column column-width=40mm/
fo:table-column column-width=40mm/
fo:table-body
fo:table-row
fo:table-cell
fo:blockHEADER CEL 1/fo:block
/fo:table-cell
fo:table-cell
fo:blockHEADER CEL 2/fo:block
/fo:table-cell
fo:table-cell
fo:blockHEADER CEL 3/fo:block
/fo:table-cell
/fo:table-row
 /fo:table-body
/fo:table
 /fo:static-content
/xsl:template

!-- Control Page Sequence Creation --
xsl:template name=ctrlPage  
xsl:if test=(position() mod 3) = 0
xsl:text disable-output-escaping=yes![CDATA[/fo:flow/fo:page-sequencefo:page-sequence master-reference=A4 

Re: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Jeremias Maerki

On 09.01.2004 18:29:14 Clóvis Wichoski wrote:
snip/
 xsl:template name=ctrlPage 
 xsl:if test=(position() mod 3) = 0
 xsl:text 
 disable-output-escaping=yes![CDATA[/fo:flow/fo:page-sequencefo:page-sequence
  
 master-reference=A4 language=pt country=br]]/xsl:text
 xsl:call-template name=header/
 xsl:text disable-output-escaping=yes![CDATA[fo:flow 
 flow-name=xsl-region-body]]/xsl:text
 /xsl:if
  /xsl:template

The problem is that you put some XML code into a CDATA section.
On-the-fly processing works with SAX. And in SAX your code will be
delivered as text instead of as elements.

snip/

 I can't understand because on the fly don't woks and from .fo file 
 generated from xml+xsl transformation work, maybe a bug of FOP, or I 
 can't generate XML elements using CDATA from this form.

The latter.

 I post this in dev list because I think that this is a feature or a bug 
 on FOP then I attached the XSL and XML files that the team can test this 
 issue, and the code is better to read than my bad English ;)

Well, bad luck. Your issue would have been a better fit for fop-user.

Jeremias Maerki



Re: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Clóvis Wichoski




Hi Jeremias,

The CDATA is only to maintain the XSL well-formed, since I close fo:flow
on another template, the tech is good, maybe dev team implement a SAX over
the stream from XML+XSL transformation option, this is the feature that I
mean.
Note that this is to reduce memory consuption.

Best regards

Clovis



Jeremias Maerki wrote:

  On 09.01.2004 18:29:14 Clvis Wichoski wrote:
snip/
  
  
xsl:template name="ctrlPage" 
xsl:if test="(position() mod 3) = 0"
xsl:text 
disable-output-escaping="yes"![CDATA[/fo:flow/fo:page-sequencefo:page-sequence 
master-reference="A4" language="pt" country="br"]]/xsl:text
xsl:call-template name="header"/
xsl:text disable-output-escaping="yes"![CDATA[fo:flow 
flow-name="xsl-region-body"]]/xsl:text
/xsl:if
 /xsl:template

  
  
The problem is that you put some XML code into a CDATA section.
On-the-fly processing works with SAX. And in SAX your code will be
delivered as text instead of as elements.

snip/

  
  
I can't understand because on the fly don't woks and from .fo file 
generated from xml+xsl transformation work, maybe a bug of FOP, or I 
can't generate XML elements using CDATA from this form.

  
  
The latter.

  
  
I post this in dev list because I think that this is a feature or a bug 
on FOP then I attached the XSL and XML files that the team can test this 
issue, and the code is better to read than my bad English ;)

  
  
Well, bad luck. Your issue would have been a better fit for fop-user.

Jeremias Maerki


  







Re: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Chris Bowditch
Clóvis Wichoski wrote:

The CDATA is only to maintain the  XSL well-formed, since I close 
fo:flow on another template, 
Opening and closing XML tags within different XSL templates is bad 
practice. You'll need to redesign your XSL stylesheet or run the XSL 
Transform as a separate process, serialize the resulting FO and then 
present the FO to FOP.

the tech is good, maybe dev team implement 
a SAX over the stream from XML+XSL transformation option, this is the 
feature that I mean.
This isnt very clear, but if you mean serializing the result of the XSL 
transform before processing the FO then I wouldnt see this as a 
desirable feature for FOP. Mainly because it will slow down processing. 
If users require this functionality then they can implement it 
themselves very easily as I suggested above.

Note that this is to reduce memory consuption.
Chris





Re: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Clóvis Wichoski
Chris Bowditch wrote:

Opening and closing XML tags within different XSL templates is bad 
practice. You'll need to redesign your XSL stylesheet or run the XSL 
Transform as a separate process, serialize the resulting FO and then 
present the FO to FOP.
But with multiple pages like 500 pages the redesign must be in XML 
source, that need redesign in all XSL too (HTML, PDF, TXT and many 
others), this cause a rework that I attempted to avoid, and only needed 
because FOP throubles with memory, this is only a relief.

Thanks for all reply

Clovis



Re: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Clay Leeds
This is just a guess, but perhaps you could do a pre-pass using XSL to 
generate multiple output pages, and then use something like iText[1] to 
concatenate your output files together.

FOP Resources:
http://xml.apache.org/fop/resources.html
I hope this helps!

Web Maestro Clay

On Jan 9, 2004, at 10:45 AM, Clóvis Wichoski wrote:
Chris Bowditch wrote:

Opening and closing XML tags within different XSL templates is bad 
practice. You'll need to redesign your XSL stylesheet or run the XSL 
Transform as a separate process, serialize the resulting FO and then 
present the FO to FOP.
But with multiple pages like 500 pages the redesign must be in XML 
source, that need redesign in all XSL too (HTML, PDF, TXT and many 
others), this cause a rework that I attempted to avoid, and only 
needed because FOP throubles with memory, this is only a relief.

Thanks for all reply

Clovis



RE: multi page-sequence don't work for (XML+XSL) to PDF on the fly

2004-01-09 Thread Andreas L. Delmelle
 -Original Message-
 From: Clovis Wichoski [mailto:[EMAIL PROTECTED]

snip /
 But with multiple pages like 500 pages the redesign must be in XML
 source, that need redesign in all XSL too (HTML, PDF, TXT and many
 others), this cause a rework that I attempted to avoid, and only needed
 because FOP throubles with memory, this is only a relief.


Hi,

Can't you use multiple page-sequences instead of just creating one sequence
'interrupted' by the 'ctrlPage' template?

A few remarks to help you on your way:
1. I can't seem to find the reason why you are placing the whole
fo:static-content  into a separate template, since it is ... well, static
and it doesn't rely on the elements in the XML (unless something is
missing).

2. In the ctrlPage template, you are testing for a position(): you could
also use XPath to select these, like

xsl:apply-templates select=product[(position() mod 3) = 0]

Then inside the product template, use

xsl:for-each select=preceding::product[position()  3] /

to grab the two preceding product nodes.

3. Check our http://xml.apache.org/fop/resources.html page, among the books
and articles, there's a link to Dave Pawson's XSLT FAQ. Over there, you'll
find a lot of useful stuff (amongst others on grouping which I think you'll
find particularly helpful), so I'll bet you can work out a redesign which
affects only the XSL itself and leaves the other files alone.

If you really can't get any further, try posting your problem on Mulberry's
XSLT list. Warning: it's a quite high-traffic list, but the upside is that
the tips are 'highly-usable' ;)

Hope this helps!

Cheers,

Andreas