AW: [xep-support] Problem with image-base-url and svg

From: <Werner.Koch@bit.admin.ch>
Date: Thu Mar 10 2005 - 05:19:44 PST

Hello Chris,

thank you for the hint, unfortunately it didn't help.

Below some code to show that system ids are set. The first part is the main
method that creates the pdf. It is worth to mention that the input xml is
created out of the aBordereauTO object and is never materialised in the
process and is just used to fire SAX events. The same holds true for the fo,
which just fires on the ContentHandler from xep/fop.

Thanks in advance for every help, even though I am quite near to give up on
this.

Current setup:
XEP - XSL Formatting Engine for Paged Media

Version 4.2 build 20050228
February 28th, 2005

on
  Windows XP SP1

with
  java version "1.4.1_03"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
  Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)

Best regards, Werner

    BordereauXMLReader r = new BordereauXMLReader();
    Source bordereauSource =
      (Source)(new SAXSource(r, new BordereauSource(aBordereauTO,
stammdaten)));

    // Create the fo renderer, set a byte stream as result.
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    ContentHandler foContentHandler = null;
    if(FOP_NOT_RENDERX == true)
    {
      // Work with fop
      foContentHandler = this.getFopContentHandler(baos);
    }
    else
    {
      // Work with xep
      foContentHandler = this.getXepContentHandler(env, baos);
    }
        
    // Create the templates and the transformer
    Transformer transformer = null;
    try
    {
      Templates templates = this.getTemplates(env);
      transformer = templates.newTransformer();
      transformer.setURIResolver(new
BordereauResolver(env.getLoggingContext().getDebugLogger()));
      transformer.setParameter(URLConstants.URL_BASE_PARAMETER_NAME,
URLConstants.getBase());
    }
    catch(TransformerConfigurationException tce)
    {
 
env.getLoggingContext().getBusinessLogger().error(TRANSFORMER_CONFIGURATION_
EXCEPTION, tce);
      throw new RM90Exception(TRANSFORMER_CONFIGURATION_EXCEPTION, tce);
    }
    catch(TransformerException te)
    {
 
env.getLoggingContext().getBusinessLogger().error(TRANSFORMER_CONFIGURATION_
EXCEPTION, te);
      throw new RM90Exception(TRANSFORMER_CONFIGURATION_EXCEPTION, te);
    }
    
    // Place the fo renderer input handler on the output of the transformer
    try
    {
      bordereauSource.setSystemId(URLConstants.getXmlFileName());
      SAXResult sr = new SAXResult(foContentHandler);
      sr.setSystemId(URLConstants.getFoFileName());
      transformer.transform(bordereauSource, sr);
    }
    catch(TransformerException te)
    {
 
env.getLoggingContext().getBusinessLogger().error(TRANSFORMER_EXCEPTION,
te);
      throw new RM90Exception(TRANSFORMER_EXCEPTION, te);
    }
    finally
    {
    }
    
    // Create the DocumentWrapper
    DocumentWrapper result = new DocumentWrapper(DocumentType.BORDEREAU);
    result.setCreationDate(new Date());
    result.setDocumentData(baos.toByteArray());
    result.setXmlData(r.getAuxiliaryOutput());
    result.setBordereauUid(aBordereauTO.getBordereauId());
    
    return result;

and

  private Templates getTemplates(Environment env) throws
TransformerConfigurationException, TransformerFactoryConfigurationError
  {
    if(m_templates == null)
    {
      TransformerFactory tf = TransformerFactory.newInstance();
      BordereauResolver aResolver = new
BordereauResolver(env.getLoggingContext().getDebugLogger());
      tf.setURIResolver(aResolver);
      Source stylesheet = null;
      try
      {
        stylesheet =
aResolver.resolve(BordereauResolver.STYLESHEET_ROOT_FILE_NAME, null);
 
stylesheet.setSystemId(BordereauResolver.getBordereauRootStylesheetSystemId(
));
      }
      catch(TransformerException te)
      {
        throw new TransformerConfigurationException("Trouble retrieving the
stylesheets", te);
      }
      m_templates = tf.newTemplates(stylesheet);
    }
    return m_templates;
  }

  private ContentHandler getFopContentHandler(ByteArrayOutputStream baos)
  {
    Driver d = new Driver();
    Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_DISABLED);
    d.setLogger(logger);
    MessageHandler.setScreenLogger(logger);
    d.setOutputStream(baos);
    d.setRenderer(Driver.RENDER_PDF);
    return d.getContentHandler();
  }
  
  private ContentHandler getXepContentHandler(Environment env,
ByteArrayOutputStream baos)
    throws RM90Exception
  {
    ContentHandler result = null;
    StreamSource config = new StreamSource(
 
this.getClass().getClassLoader().getResourceAsStream(BordereauResolver.XEP_C
ONFIG_FILE_URL));
 
config.setSystemId("resource:/ch/admin/bit/edec/core/services/documents/inte
rnal/utilxml/xep.xml");
    try
    {
      if(this.m_xepFormatter == null)
      {
        Properties p = new Properties();
        p.put("ROOT",
"resource:/ch/admin/bit/edec/core/services/documents/internal/utilxml/");
        this.m_xepFormatter =
          new FormatterImpl(config, p,
com.renderx.xep.lib.Logger.NULL_LOGGER);
      }
      

      result = this.m_xepFormatter.createContentHandler(
          BordereauResolver.INPUT_FILE_NAME, new FOTarget(baos, "PDF"));
    }
    catch(ConfigurationException ce)
    {
 
env.getLoggingContext().getBusinessLogger().error(XEP_CONFIGURATION_EXCEPTIO
N, ce);
      throw new RM90Exception(XEP_CONFIGURATION_EXCEPTION, ce);
    }
    
    return result;
  }

-----Ursprüngliche Nachricht-----
Von: owner-xep-support@renderx.com [mailto:owner-xep-support@renderx.com] Im
Auftrag von Chris Bowditch
Gesendet: Donnerstag, 10. März 2005 12:17
An: xep-support@renderx.com
Betreff: Re: [xep-support] Problem with image-base-url and svg

Werner.Koch@bit.admin.ch wrote:

> I have a problem with a message indicating a missing image-base-url,
> see also the small excerpt of the stack trace below.
>
> Caused by: com.renderx.xep.lib.InternalException: attribute
> 'image-base-url' is required but missing
> at com.renderx.xep.pre.AttList.getDefault(Unknown Source)
>
> I followed the advice I found scatterd in the mail list and assigned
> everywhere in my process system ids to stylesheets , sources and
> results if possible and sometimes even xml:base attributes, even
> though the only external graphic that needs to be loaded was
> referenced with an absolute path. After some fooling around, I found
> out that it was not the external graphic, that causes the trouble, but
> a <fo:instream-foreign-object> which carries an svg graphic. The svg
> graphic is a barcode created by your barcode library code128.xslt, and
> removing the svg from the fo resolves the missing image-base-url
> problem along with removing the barcode. So I guess, I have to set
> somewhere something on this svg object. Putting an xml:base on the
> element svg didn't help, so I need some help.

I encountered the same problem, but setting systemId on the SAXSource object

thats passed to formatterImpl.render method fixed the problem. If you are
already doing this then it might be worth upgrading to 4.2.

Chris

-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support' in
the body of the message to majordomo@renderx.com from the address you are
subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service
http://www.renderx.com/tos.html
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html
Received on Thu Mar 10 06:18:06 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 10 2005 - 06:18:06 PST