opensubscriber
   Find in this group all groups
 
Unknown more information…

f : fop-users@xmlgraphics.apache.org 17 October 2007 • 1:35AM -0400

Re: The entity "nbsp" was referenced, but not declared.
by Abel Braaksma

REPLY TO AUTHOR
 
REPLY TO GROUP



Murali Krishna wrote:
> Hi Abel,
> Thanks for reply.I've include the Doctype that you have prescribed and
> make
> the html and xsl document well formed .The xalan commend processed the
> file.But the generated fo file is a corrupted one and does not include
> any
> xsl styling and when input to the FOP it generated a exception as
> follows:Please find the attached xsl and html files used.
> [Fatal Error] raj_test.fo:12:13: Content is not allowed in prolog.
> javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
> Content is not allowed in prolog.

Whenever you see that message, something is seriously wrong. It means,
usually, that there's content which is not a comment, not a PI, and not
an xml declaration before the root opening tag.

Though XSL requires XML as input, you can create any output (and only
with XSLT 2.0 you can force a certain output format with validation, but
you are using XSLT 1.0).

I didn't look through your XSL file yesterday. Considering the
complexity, I assume you didn't make this XSL file yourself? But the
stylesheet creator seems to have some misunderstanding on what XML
Entities are for and when you need them and when not. The endless entity
declarations inside the xsl:text are useless, they serve no purpose.
Once you process a file with and XSLT processor, the processor will make
sure the output XML will be valid UTF-8, containing all entities as
characters.

Your input XML is still not _valid_ XML (don't you yet use an XML
editor? It will save you a *lot* of trouble!), but it is well-formed and
as such will be processed by the XSL processor.

However, since we converted it to XHTML and used its doctype, the
namespace of the html nodes is "http://www.w3.org/1999/xhtml" (this is
either implicitly, by the doctype DTD, or explicitly, by setting it
manually). Since the XSLT stylesheet does not use any namespace, you
will have to declare it and use it. Unfortunately, you will have to add
your chosen prefix to each and every XPath (this is an XSLT 1.0 "feat",
in XSLT 2.0, you don't need to anymore with xpath-default-namespace).

So you have basically three solutions:
  1. set the namespace in the XSLT so that it can find the matching elements
  2. remove the namespace in the XML source (by removing the XHTML
declaration), but this means you will have to add the entity
declarations manually
  3. like (1) but then with XSLT 2.0, just add xpath-default-namespace
to the root stylesheet element.

I tried (3) and it works. Like I said in an earlier post, your awkward
  scattered all over the place will not give you pretty PDF.

The output you saw (the "corrupted" output) was from the default
template of the XSLT stylesheet (because no template matching rule
satisfied), the one that is always there, even when you do not declare
any template yourself. This is a very basic FAQ. Follow the link I gave
you earlier and read around in the FAQ, or find some tutorial. I
personally find Jeni Tenisson's books rather good as an introduction to
XSLT.

HTH,
Cheers,
-- Abel Braaksma

PS: general XSLT questions are still best asked on the XSL list. This
list is for FOP. You will find the people on the XSL list very helpful,
esp. if you first visit the FAQ before posting.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlg...
For additional commands, e-mail: fop-users-help@xmlg...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

opensubscriber is not affiliated with the authors of this message nor responsible for its content.