Search code examples
javaapache-fop

Apache FOP and xsi:schemaLocation - how to ignore?


I have in my XSL-FO file a xsi:schemaLocation just to know, what attributes/tags are available. Unfortunatelly I getting an exception from the transformet:

org.apache.fop.fo.ValidationException: Invalid property encountered on "fo:root": xsi:schemaLocation

On the FopFactory I see, there is a method called ignoreNamespace, but it doesn't work or I don't know how to write it properly. I got:

FopFactory fopFactory = FopFactory.newInstance();
fopFactory.ignoreNamespace("xsi:schemaLocation");

How to do it right?

My root of the XSL-FO looks that:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            font-family="Arial" 
            xsi:schemaLocation="http://www.w3.org/1999/XSL/Format http://www.xmlblueprint.com/documents/fop.xsd">

Solution

  • The ignoreNamespace function takes the namespace identifier, which in this case is the URL: http://www.w3.org/2001/XMLSchema-instance. The following should fix the issue for you:

    fopFactory.ignoreNamespace("http://www.w3.org/2001/XMLSchema-instance");