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 Richard Bondi <rb...@ergito.com> on 2002/07/30 18:20:30 UTC

XmlSpy + FOP Minireview

XmlSpy + FOP Note
=================

The FOP list gets questions from XmlSpy users often enough that I feel this 
tiny review of the program will be useful. I wrote it:

- to provide enough background on Spy for non-Spy users to decide whether 
an FOP post is an XmlSpy or an FOP problem

- to minimize frustration when evaluating the free XmlSpy trial by 
providing information that is not in the documentation (or anywhere else 
AFAIK).

Disclaimer: I'm a paid-up user, that's all. I'm not affiliated with the 
company in any way.

What is it?
===========
XmlSpy (hereafter Spy) is a $400 Windows-based IDE for doing xml/xsl/fo 
development. You can download a fully functional 30 day trial from 
www.XmlSpy.com.

With or without Spy, using fop typically requires two steps:

- 1) Transforming some XML to an FO document (XML + XSLT -> FO);
- 2) Transforming the FO document to a pdf with FOP (FO + FOP -> PDF).

Each of these sections below starts with a brief overview. It is followed 
by information useful to anyone actually using the program.

XML + XSLT -> FO
================

Overview
--------
To do a transform in Spy, open or create an Xml and Xsl file. Bring the Xml 
window in front, and assign the Xslt file to it from the Xsl->Assign Xsl 
window. Then press F10. The output will appear in a new window.

How Spy displays it will depend on <xsl:output> or the output file 
extension you set in Tools -> Options -> XSL tab -> "Default extension of 
output file".

Spy does not do any transforms itself. Instead, you can choose different 
Xslt processors in the same dialog box; Spy simply passes through your 
inputs, then captures the output.

Details
-------
First, you need to edit your xml. There's a text-editor that color codes 
all tags, and pops up known tags (IntelliSense) if you've associated a DTD 
with the xml file. There's also a vaguely excel-like grid view (the 
Enhanced Grid View) which I rarely find useful.

If you don't have a DTD or Schema, Spy can generate one for you fairly 
intelligently from your xml file; that's quite useful. Otherwise, DTDs can 
easily be written with IntelliSense.

Spy shines with huge files; I often have to manipulate xml files of about 5Meg.

One bug: if you open the xml file in text view, it will validate in the 
background without telling you. This means you'll think the file is error 
free when in fact Spy just hasn't found any yet. A simple work-around is to 
switch to grid view, which validates for well-formedness almost instantly.

When well-formedness errors are found, Spy puts the cursor at the error and 
scrolls to it. It also does this with the results of a transform. This is 
obviously extremely useful, but of course sometimes Spy can't tell where to 
go.  (Consider: <root><tag1>1000 lines of text <tag1> 2000 lines of text 
</tagl>1000 lines of text </root>. Neither Spy nor anyone else can say 
which <tag1> tag you forgot to close if they are nestable, and you'll have 
hard time scrolling with all that text).

If you validate against a DTD, Spy scrolls to the offending tag in the xml.

Different Transformers
----------------------
You can use just about any xslt processor, since Spy just "passes through" 
your inputs. By default, Spy uses msxml 3; msxlm 4 is a radio button away 
(if you have installed it) in Tools -> Options -> XSL tab. The 
documentation doesn't describe how to use Saxon or Xalan, so I'll do it here.

- go to Tools -> Options -> XSL tab
- check "External transformation program"
- For Instant Saxon, enter:
	[your absolute path here]\saxon.exe -l -t -o %2 %1 %3
- For Xalan 1.x, enter:
	[your JAVA_HOME here]\java -cp [your xalan.jar path here]\xalan.jar 
org.apache.xalan.xslt.Process -in %1 -xsl %3 -out %2

(Msxml is the speed demon, Saxon's probably as fast but needs to start the 
jvm; and Xalan is shockingly slow: add the -diag to switch to actually time 
it. Xalan 2 doesn't seem much faster to me.)

Controlling Output
------------------
To override or replace <xsl:output>, enter the extension you want in Tools 
-> Options -> XSL tab -> "Default extension of output file".
- For FOP, this would be .fo.
- If you want to be able to view your transformed html output in a browser 
window by selecting Grid View, enter .htm or .html. Otherwise, your html 
transform output will appear in a Spy window with a big warning about how 
it is not well-formed.
- To transform to Xml, put in .xml.

FO + FOP -> PDF
===============

Overview
--------
- Set your output type to .fo in Tools -> Options -> XSL tab -> "Default 
extension of output file".
- Transform an xml file to .fo, as described above.
- With the output .fo file in front, press Control-F10.

You can then choose various PDF outputs from a dialog, including the fop 
Swing viewer and Acrobat (which of course has to be on your machine already).

Acrobat will conveniently be opened, or be brought in front, if you choose 
it. Note that Acrobat cannot open the same file twice without upsetting 
fop, so close the previous fop transform before generating a pdf.

Note
----
Setting your output type to .fo in Tools -> Options -> XSL tab -> "Default 
extension of output file" is important (and undocumented). If you don't, 
but set it to e.g. .xml, then pressing F10 will generate an irritating 
error message. Basically, Spy doesn't know what to do because it doesn't 
realize you have generated an .fo file: it thinks you've generated .xml, 
and that you can't run FOP on that. To get any further, you'd have to copy 
the entire file, create a new FO window from File -> New, and paste it in; 
only then would Control-F10 work. So set your default output type to .fo 
instead!

Details
-------
Telling Spy to use fop is a lot like telling it what Xslt processor to use 
-- except there's a bug.

In Tools -> Options -> XSL tab, there's a field at the bottom to enter 
fop.bat. After having made sure fop.bat works from the command line, enter:
	[your absolute path to fop.bat here]\fop.bat

I also enter the -d switch for debugging output; you can add any fop switches.

The Bug
-------
Problems arise if, for your example, you have generated font files and want 
to pass in userconfig.xml as a parameter.

With Apache formatting objects 2.03 and 2.04rc, one cannot add the command 
line option for the user config file via Spy. In other words, this won't 
work in the fop box:

	[your absolute path to fop.bat here]\fop.bat -c conf\userconfig.xml

With both fop versions, you get a NoClassDefFound error immediately.

The Workaround
--------------
The workaround is to put "-c conf/userconfig.xml" directly into the fop.bat 
file, but you have to do it carefully: the only place it won't generate odd 
errors in Spy is directly before the parameter placeholders. Example fop.bat:

c:\jdk1.4\bin\java -cp 
build\fop.jar;lib\batik.jar;lib\xalan-2.3.1.jar;lib\xercesImpl-2.0.1.jar;lib\xml-apis.jar;lib\avalon-framework-cvs-20020315.jar;lib\logkit-1.0.jar;lib\jimi-1.0.jar 
org.apache.fop.apps.Fop -c conf\userconfig.xml %1 %2 %3 %4 %5 %6 %7 %8

Final Notes
===========
My biggest complaint with Spy is its lack of regular expressions; I'm 
constantly switching in and out of Textpad to clean up files. The 
Find/Replace in grid view looks powerful, but I've never really been able 
to understand it; it certainly never acts as expected.

Customer Support is good. Questions are answered in 24 hours, and usually 
by someone who is knowledgeable and clear.

If nothing else, Spy is an excellent tool for teaching Xslt. Xslt may not 
be that hard to use, but of the 10 or so programming languages I've 
learned, it was by far the hardest to learn. Spy allows you to at least 
strip away the equally formidable barriers of learning how to use a DOM 
parser and Xslt processor. You can sit them down, give them Michael Kay's 
book, and focus completely on Xslt.


Richard Bondi, 7/30/02
www.ergito.com
www.cryptovb.com


Re: warning message

Posted by Chuck Paussa <Ch...@systems.dhl.com>.
Anupam Sood wrote:

>Hi
>
>I get the following WARN message, any idea how can I fix this
>
>WARN    10281   [fop     ] (): Sum of fixed column widths 170078 greater than maximum specified IPD 0
>
>thanks
>
>anupam
>
>  
>
That means that you've got some content that is wider than the width of 
the container in which it sits.

For instance, a table within a table cell where the table-cell's column 
has a width of 1 inch and the table has a width of 1.1 inch.



warning message

Posted by Anupam Sood <An...@morganstanley.com>.
Hi

I get the following WARN message, any idea how can I fix this

WARN    10281   [fop     ] (): Sum of fixed column widths 170078 greater than maximum specified IPD 0

thanks

anupam


Re: XmlSpy + FOP Minireview

Posted by "Randall J. Parr" <RP...@TemporalArts.COM>.
Richard Bondi wrote:

> XmlSpy + FOP Note
> =================
>
Thanks.  Very helpful.

I, for one, appreciate this kind of concise docment.

R.Parr
Temporal Arts