You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Robert Burghart <je...@gmail.com> on 2007/12/09 04:42:18 UTC

ProtocolHandlers

As part of the project I'm working on I need to have batik retrieve
referenced files from a local database.  To do this I figured I should
extend either ParsedURLDefaultProtocolHandler or
AbstractParsedURLProtocolHandler so I could return my own extended version
of ParsedURLData which would establish the database connection and return an
InputStream for processing.  While trying to implement this I encountered a
possible bug.
Setup:
Library: batik1.7beta1
JDK: 1.5 (Apple)
OS: MacOS 10.5

The protocol link I wanted would be something like:  "library:
fileName.ext#ref" and would be used to call for images, css files and other
svg files.  I have found two problems with this setup:
1 - Batik doesn't use protocol handlers for css files referenced in
<?xml-stylesheet ?>
2 - Batik still tries to create a URL object even tho the ParsedURL has
already returned data.

CSS Loading
org.w3c.dom.DOMException: Null Document reference:
Invalid CSS document.
at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(CSSEngine.java
:1167)
at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(CSSEngine.java
:1127)
at
org.apache.batik.dom.svg.SVGStyleSheetProcessingInstruction.getCSSStyleSheet
(SVGStyleSheetProcessingInstruction.java:104)
at org.apache.batik.css.engine.CSSEngine.getStyleSheetNodes(CSSEngine.java
:934)
at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java
:796)
at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java
:878)
at org.apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java
:82)
at org.apache.batik.bridge.CSSUtilities.convertVisibility(CSSUtilities.java
:579)
at org.apache.batik.bridge.SVGSVGElementBridge.createGraphicsNode(
SVGSVGElementBridge.java:132)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:72)
at org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:96)

It's important to note that my protocol handler is *never* called when batik
tries to open the css file.


SVG Loading
org.apache.batik.bridge.BridgeException: Malformed URL:
library:SOPOS_1_1.regions
at org.apache.batik.bridge.BridgeContext.getReferencedNode(
BridgeContext.java:781)
at org.apache.batik.bridge.BridgeContext.getReferencedElement(
BridgeContext.java:797)
at org.apache.batik.bridge.SVGUseElementBridge.buildCompositeGraphicsNode(
SVGUseElementBridge.java:123)
at org.apache.batik.bridge.SVGUseElementBridge.createGraphicsNode(
SVGUseElementBridge.java:97)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:206)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:164)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:78)
at org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:96)

When it's trying to load the SVG document the problem is in
SAXSVGDocumentFactory.java in createDocument(String uri) on line 204.

Currently I have solved my problems by registering an extended
URLStreamHandlerFactory with URL.setURLStreamHandlerFactory().  I also have
to create extended forms of both URLStreamHandler and URLConnection but it
loads all the files properly (including css) and I don't need
either ParsedURLDefaultProtocolHandler or AbstractParsedURLProtocolHandler.

-- 
- Robert

Re: ProtocolHandlers

Posted by Cameron McCormack <ca...@mcc.id.au>.
Hi Robert.

Robert Burghart:
> As part of the project I'm working on I need to have batik retrieve
> referenced files from a local database.  To do this I figured I should
> extend either ParsedURLDefaultProtocolHandler or
> AbstractParsedURLProtocolHandler so I could return my own extended version
> of ParsedURLData which would establish the database connection and return an
> InputStream for processing.  While trying to implement this I encountered a
> possible bug.
>
> Setup:
> Library: batik1.7beta1

I haven’t got time to look into it in detail at the moment, but have you
tried the latest code from Subversion?  Since the 1.7beta1 release,
there have been some changes to make more use of ParsedURL instead of
URL in various places.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org