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 Eric Pement <er...@moody.edu> on 2003/04/25 18:53:09 UTC

newbie help on error message

<warning>Newbie alert</warning>

I've been given the assignment of generating .PDFs from .XML files.
So I've installed FOP, and had it working mostly successfully from
the command line (i.e., the /fop/examples/fo will compile).

What I need to do now is to create an .XSL file, which will create the
.FO file ... and you know the rest. Problem is, I didn't write the .XML
file and I'm at a novice level in all of this. So I'd like to build the
.XSL file incrementally, seeing if I can print single tags from the .XML
file, and then successively adding tags until I have a generalized
solution that will work on whatever .XML file we feed it which obeys
the given schema.

Right now, I'm getting an error message, "fo:flow must contain block-level
children", which I don't know what to do with.  My input xsl code is this
(with nonessentials removed):

  <fo:flow flow-name="xsl-region-body">
      <xsl:apply-templates select="Title" />
  </fo:flow>

  . . .

  <xsl:template match="Title[@t_style='title_1']">
    <fo:block
      font-size="24pt" line-height="28pt" text-align="start"
      font-family="Helvetica" font-weight="bold" color="blue"
      space-after.optimum="12pt">
      <xsl:value-of select="Title" />
    </fo:block>
  </xsl:template>

I want to insert the value of the <Title> tag if there is a
t_style attribute of "title_1".  And as you might guess, later
on if the attribute says "title_2", I select a different font
size, color, and so forth.

I don't know why this error message is occurring, since I think
the "block-level children" are invoked by the match. I would
also like some pointers, web links or ideas on building an
.XSL file in stages, since I seem to be failing even on the
first steps. Thanks in advance.


-- 
Eric Pement - eric.pement@moody.edu
Education Technical Services, MBI


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


RE: Some Resources (was Re: newbie help on error message)

Posted by Victor Mote <vi...@outfitr.com>.
Clay Leeds wrote:

> While we're on the subject of books and resources for FOP Resources,
> here's a couple things to add. One of my previous posts included a list
> of good books on XSL-FO (some of which you've listed). Here's a link to
> my post.
>
> http://marc.theaimsgroup.com/?l=fop-user&m=104463666315238&w=2

OK, I have added links to "XPath and XPointer" (yes, that is a good one),
the XPath Visualizer tool, "XSL Essentials".

"The XML Bible" was already on the list, but I did rework the whole thing
today to link to both the online version & the hardcopy version.

> - Definitive XSL-FO, by G. Ken Holman - ISBN: 0131403745
>   (Chapter 8 - "Floats & Footnotes" online at Amazon)
> - XSL Formatting Objects, by Doug Lovell - ISBN: 0672322811
>   (Chapter 3 - "Tools & Implementations" online at Amazon)

I have added them.

> BTW, it'd be great to add Amazon.com links to the selected books which
> include "donation" information for FOP (or Apache or Jeremias--I'm
> pluggin' for ya!--or whomever?). That way, links to good books from the
> highly trafficked FOP Resources page could actually bring in a bit of $$
> to help pay for coffee, Mtn Dew, donuts or paper?

I am not sure what Apache's policies are, but my preference is to keep the
links extremely professional. If we add Amazon links, do we need to add B&N?
What about Amazon UK or Amazon Japan? I don't think I want to go there. I
think our users can probably figure out how to find their favorite online
bookstore. (It is a good idea though -- feel free to raise it on the fop-dev
mailing list if you feel strongly about it).

Victor Mote


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


Some Resources (was Re: newbie help on error message)

Posted by Clay Leeds <cl...@medata.com>.
Victor,

While we're on the subject of books and resources for FOP Resources,
here's a couple things to add. One of my previous posts included a list
of good books on XSL-FO (some of which you've listed). Here's a link to
my post.

http://marc.theaimsgroup.com/?l=fop-user&m=104463666315238&w=2

Aside from the usual suspects of good XSL-FO books, it also includes a
link to the excellent XPath Visualizer which unfortunately only runs in
Internet Exploiter :-(

XPath Visualizer:
   http://www.vbxml.com/xpathvisualizer/

Extra Credit:
(I "hand wrote" the signature on that message in a spate of frustration
regarding all of the "This msg intended for recipient..." sigs. Looking
back on it, it's pretty funny! ;-]

In addition, there are two new books:

- Definitive XSL-FO, by G. Ken Holman - ISBN: 0131403745
  (Chapter 8 - "Floats & Footnotes" online at Amazon)
- XSL Formatting Objects, by Doug Lovell - ISBN: 0672322811
  (Chapter 3 - "Tools & Implementations" online at Amazon)

(I haven't seen them, anyone have a review)

BTW, it'd be great to add Amazon.com links to the selected books which
include "donation" information for FOP (or Apache or Jeremias--I'm
pluggin' for ya!--or whomever?). That way, links to good books from the
highly trafficked FOP Resources page could actually bring in a bit of $$
to help pay for coffee, Mtn Dew, donuts or paper?

;-)

Victor Mote wrote:
> J.Pietschmann wrote:
> 
> 
>>Buy Mike Kay's book on XSLT (ISBN 1861005067) and perhaps
>>D.Pawsons book about XSLFO (ISBN 0596003552) and work through
>>the examples. It is usually unwise to learn a new technology on
>>the job.
>>
>>Victor: as usual, something for the ressources page?
> 
> 
> Good idea -- I just committed a change that has both of these. I also added
> the O'Reilly book "XSLT Cookbook", for which I have seen some good reviews.
> I hadn't heard about that one until this week. I hope to publish the web
> site this weekend.
> 
> BTW, I think it is good to learn new technology on the job. In fact, having
> a real-world problem is about the only way I can learn anything. However,
> you do want to have your books at hand as you do it, which is probably what
> you meant anyway.


-- 
Clay Leeds - cleeds@medata.com
Web Developer - Medata, Inc. - http://www.medata.com
PGP Public Key: https://mail.medata.com/pgp/cleeds.asc


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


Re: newbie help on error message

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Victor Mote wrote:
> BTW, I think it is good to learn new technology on the job. In fact, having
> a real-world problem is about the only way I can learn anything. However,
> you do want to have your books at hand as you do it, which is probably what
> you meant anyway.

I meant: It is bad to be thrown at a problem without any experience,
mentoring or guide, at least if complex technologies like XSLT or XSLFO
are involved. I've seen a lot people aquiering bad habits this way.
Often they start with copycatting simple examples, then struggle along
always taking the first approach which seems to work without ever
learning the concepts of the technology properly and ultimately get
stuck.

I suggest to take classes in parallel to the job, or have an experienced
mentor (that's the way apprenticeship is handled in engineering), or at
least take a dedicated self-study with some paper ressources.

J.Pietschmann


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


RE: newbie help on error message

Posted by Victor Mote <vi...@outfitr.com>.
Victor Mote wrote:

> Good idea -- I just committed a change that has both of these. I
> also added
> the O'Reilly book "XSLT Cookbook", for which I have seen some
> good reviews.
> I hadn't heard about that one until this week. I hope to publish the web
> site this weekend.

Sorry. I meant to throw the content in here for Eric's benefit (until the
web site is published):

http://wrox.com/books/1861005067.htm XSLT Programmer's Reference, by Michael
H. Kay, Wrox Press, ISBN 1-861-00506-7.

http://www.oreilly.com/catalog/xslt XSLT, by Doug Tidwell, O'Reilly &
Associates, 2001, ISBN 0-596-00053-7.

http://www.oreilly.com/catalog/xsltckbk XSLT Cookbook, by Sal Mangano,
O'Reilly Associates, 2002, ISBN 0-596-00372-2.

Victor Mote


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


RE: newbie help on error message

Posted by Victor Mote <vi...@outfitr.com>.
J.Pietschmann wrote:

> Buy Mike Kay's book on XSLT (ISBN 1861005067) and perhaps
> D.Pawsons book about XSLFO (ISBN 0596003552) and work through
> the examples. It is usually unwise to learn a new technology on
> the job.
>
> Victor: as usual, something for the ressources page?

Good idea -- I just committed a change that has both of these. I also added
the O'Reilly book "XSLT Cookbook", for which I have seen some good reviews.
I hadn't heard about that one until this week. I hope to publish the web
site this weekend.

BTW, I think it is good to learn new technology on the job. In fact, having
a real-world problem is about the only way I can learn anything. However,
you do want to have your books at hand as you do it, which is probably what
you meant anyway.

Victor Mote


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


Re: newbie help on error message

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Eric Pement wrote:
> Right now, I'm getting an error message, "fo:flow must contain block-level
> children", which I don't know what to do with.

It means exactly what it says.
> 
>   <fo:flow flow-name="xsl-region-body">
>       <xsl:apply-templates select="Title" />
>   </fo:flow>
>   . . .
>   <xsl:template match="Title[@t_style='title_1']">
>     <fo:block

Chances are that your template isn't matched for whatever reason,
and the flow turns out empty or perhaps with text supplied from
default templates.

> I don't know why this error message is occurring, since I think
> the "block-level children" are invoked by the match.

Well, inspect the FO file to be *sure*.

> I would
> also like some pointers, web links or ideas on building an
> .XSL file in stages, since I seem to be failing even on the
> first steps. Thanks in advance.

Buy Mike Kay's book on XSLT (ISBN 1861005067) and perhaps
D.Pawsons book about XSLFO (ISBN 0596003552) and work through
the examples. It is usually unwise to learn a new technology on
the job.

Victor: as usual, something for the ressources page?

J.Pietschmann



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


Re: newbie help on error message

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Eric Pement wrote:
> So I no longer get the error message. However, the content
> of the <fo:blocks> is now empty, and whatever is in the <Title>
> tags is being ignored and not printed in the output document.
> 
> All Xalan did was to confirm that nothing is printed in the 
> output. Problem is, it didn't tell me exactly why the content
> is being skipped. I guess I have more to discover.

>>>  <xsl:template match="Title[@t_style='title_1']">
>>>    <fo:block
>>>      font-size="24pt" line-height="28pt" text-align="start"
>>>      font-family="Helvetica" font-weight="bold" color="blue"
>>>      space-after.optimum="12pt">
>>>      <xsl:value-of select="Title" />
                               ^^^^^^
This will only result in a value if you have a Title element
in the matched Title element.

However, I guess the above template didn't match at all. There
is no way to tell why whithout knowing the match pattern for the
template which produces the fo:flow and the relevat part of the
source XML.

J.Pietschmann


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


RE: newbie help on error message

Posted by Victor Mote <vi...@outfitr.com>.
Eric Pement wrote:

> So I no longer get the error message. However, the content
> of the <fo:blocks> is now empty, and whatever is in the <Title>
> tags is being ignored and not printed in the output document.
>
> All Xalan did was to confirm that nothing is printed in the
> output. Problem is, it didn't tell me exactly why the content
> is being skipped. I guess I have more to discover.
>
> I changed this:
>
> >>   <xsl:template match="Title[@t_style='title_1']">
> >>     <fo:block
> >>       font-size="24pt" line-height="28pt" text-align="start"
> >>       font-family="Helvetica" font-weight="bold" color="blue"
> >>       space-after.optimum="12pt">
> >>       <xsl:value-of select="Title" />
> >>     </fo:block>
> >>   </xsl:template>
>
>
> and replaced <xsl:value-of ...> to <xsl:apply-templates> and it
> didn't help either. If anyone has any other suggestions, PLEASE
> pipe in and suggest something. Thanks much!!

First, one of the things that was not in your original posting is the
template that your
      <xsl:apply-templates select="Title" />
occurs in. So the first question is whether a "Title" element occurs in the
context of that template.

Second, your template implies that there needs to be not just a Title
element in the context, but one with the attribute t_style="title_1". So you
need to see whether that is true.

Third, I have some doubts whether
      <xsl:apply-templates select="Title" />
is going to find a match in:
      <xsl:template match="Title[@t_style='title_1']">
The fact that I have never seen it done before is not definitive, but it is
worrisome. I would use a different approach, at least to help in debugging
here, if the first two ideas above don't yield results. As I stated in an
earlier posting, if you see evidence that the match isn't occurring (and you
have), then have your template match any <Title> element, and put
conditional logic inside the template to handle the differences between
attributes.

Fourth, even if any of this works, your <xsl:value-of select="Title"> will
probably not give you any results, because there is probably not going to be
an XPath expression that will match "Title" inside of your template for the
<Title> element. You probably want instead: <xsl:value-of select="."> If
your FO file has both <elements> in it (the one you wrapped around the
apply-templates, plus the one inside the Title template), then this is
probably all you need to fix. Otherwise, I think you have two problems.

Again, this is not the right forum to debug XSLT, nor to tutor in it. I hope
the resources posted earlier & the above ideas give you enough to chew on to
get going again.

Victor Mote


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


RE: newbie help on error message

Posted by Eric Pement <er...@moody.edu>.
At 12:25 PM 4/25/2003 -0600, Victor Mote wrote:

>Eric Pement wrote:
>> Right now, I'm getting an error message, "fo:flow must contain block-level
>> children", which

   I've fixed the error message, by changing

>>   <fo:flow flow-name="xsl-region-body">
>>       <xsl:apply-templates select="Title" />
>>   </fo:flow>


To this:
   
  <fo:flow flow-name="xsl-region-body">
      <fo:block>
          <xsl:apply-templates select="Title" />
      </fo:block>
  </fo:flow>

So I no longer get the error message. However, the content
of the <fo:blocks> is now empty, and whatever is in the <Title>
tags is being ignored and not printed in the output document.

All Xalan did was to confirm that nothing is printed in the 
output. Problem is, it didn't tell me exactly why the content
is being skipped. I guess I have more to discover.

I changed this:

>>   <xsl:template match="Title[@t_style='title_1']">
>>     <fo:block
>>       font-size="24pt" line-height="28pt" text-align="start"
>>       font-family="Helvetica" font-weight="bold" color="blue"
>>       space-after.optimum="12pt">
>>       <xsl:value-of select="Title" />
>>     </fo:block>
>>   </xsl:template>


and replaced <xsl:value-of ...> to <xsl:apply-templates> and it
didn't help either. If anyone has any other suggestions, PLEASE
pipe in and suggest something. Thanks much!!


-- 
Eric Pement - eric.pement@moody.edu
Education Technical Services, MBI


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


RE: newbie help on error message

Posted by Victor Mote <vi...@outfitr.com>.
Eric Pement wrote:

> file and I'm at a novice level in all of this. So I'd like to build the
> .XSL file incrementally, seeing if I can print single tags from the .XML
> file, and then successively adding tags until I have a generalized
> solution that will work on whatever .XML file we feed it which obeys
> the given schema.

That is a sound approach.

> Right now, I'm getting an error message, "fo:flow must contain block-level
> children", which I don't know what to do with.  My input xsl code is this
> (with nonessentials removed):
>
>   <fo:flow flow-name="xsl-region-body">
>       <xsl:apply-templates select="Title" />
>   </fo:flow>
>
>   . . .
>
>   <xsl:template match="Title[@t_style='title_1']">
>     <fo:block
>       font-size="24pt" line-height="28pt" text-align="start"
>       font-family="Helvetica" font-weight="bold" color="blue"
>       space-after.optimum="12pt">
>       <xsl:value-of select="Title" />
>     </fo:block>
>   </xsl:template>
>
> I want to insert the value of the <Title> tag if there is a
> t_style attribute of "title_1".  And as you might guess, later
> on if the attribute says "title_2", I select a different font
> size, color, and so forth.

I'm no XSLT expert, so your approach might be OK. However I would recommend
making your template match = "Title", then putting an <xsl:if> inside the
template to deal with the difference in attributes, perhaps by pointing to
separate templates for the two styles.

> I don't know why this error message is occurring, since I think
> the "block-level children" are invoked by the match. I would
> also like some pointers, web links or ideas on building an
> .XSL file in stages, since I seem to be failing even on the
> first steps. Thanks in advance.

You will benefit first from looking at this page:
http://xml.apache.org/fop/running.html#running_xalan

By using the xalan script, you can store & later look at the actual FO code
that is created by the transformation. This will tell you whether your
stylesheet actually did what you intended.

Also, check out:
http://xml.apache.org/fop/resources.html#specs and
http://xml.apache.org/fop/resources.html#articles

Victor Mote


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