You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Stefano Mazzocchi <st...@apache.org> on 2000/08/21 12:18:04 UTC

[bug] missing fo prefix

I'm currently playing around with Cocoon 2.0a2 and I'm trying to
integrate FOP 0.14.0 into it and I stepped into the "Unknown namespace
prefix fo" problem.

Ricardo Lagos suggested to put

   parser.setFeature(
                "http://xml.org/sax/features/namespace-prefixes", true);

to make the parser leave namespace prefixes into the elements, but this
is indeed wrong. FOP should _NOT_ assume the existance of namespace
prefixes inside the elements, otherwise the whole point of namespaces is
gone.

Moreover, SAX2 deprecates this feature and leaves it there just to match
with old programs that were not fully namespace aware and would be
broken by such changes.

The problem seems to be in FOTreeBuilder where

	for (int i = 0; i < length; i++) {
	    String att = attlist.getQName(i);
	    if (att.equals("xmlns")) {
		namespaceStack.push( new NSMap("",
					       attlist.getValue(i),
					       level));
	    } else if (att.startsWith("xmlns:")) {
		String value = attlist.getValue(i);
		namespaceStack.push(new NSMap(att.substring(6), value,
					      level));
	    }
	}

which clearly cannot work as expected if the namespace prefixes are
removed and passed along with SAX events, rather than inside element
names and attributes.

This breaks FOP operation inside a wealthy SAX2 application which
Cocoon2 tries to be.

The fix is not trivial since I can't estimate how many spots must be
changed to enforce good SAX2 compliance, but it's not hard: it's just a
matter of implementing the namespace hook methods and work on them
instead of reparsing the element names and xmlns attributes to find
namespaces.

Until this is fixed, Cocoon cannot work with FOP at all :( I'd love to
help but I currently don't have time to play around with FOP since I'm
trying to exit the Cocoon2 alpha stage (which is much more important to
me at this point).

Hope this helps.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------