org.apache.batik.apps.svgbrowser
Class XMLInputHandler

java.lang.Object
  |
  +--org.apache.batik.apps.svgbrowser.XMLInputHandler
All Implemented Interfaces:
SquiggleInputHandler

public class XMLInputHandler
extends java.lang.Object
implements SquiggleInputHandler

This implementation of the SquiggleInputHandler class handles XML files by looking for the first <?xml-stylesheet ... ?> processing instruction referencing an xsl document. In case there is one, the transform is applied to the input XML file and the handler checks that the result is an SVG document with an SVG root.


Inner Class Summary
 class XMLInputHandler.DocumentURIResolver
          Implements the URIResolver interface so that relative urls used in transformations are resolved properly.
 
Field Summary
static java.lang.String ERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTION
           
static java.lang.String ERROR_RESULT_GENERATED_EXCEPTION
           
static java.lang.String ERROR_TRANSFORM_OUTPUT_NOT_SVG
           
static java.lang.String ERROR_TRANSFORM_OUTPUT_WRONG_NS
           
static java.lang.String ERROR_TRANSFORM_PRODUCED_NO_CONTENT
           
static java.lang.String PSEUDO_ATTRIBUTE_HREF
           
static java.lang.String PSEUDO_ATTRIBUTE_TYPE
           
static java.lang.String XSL_PROCESSING_INSTRUCTION_TYPE
           
static java.lang.String[] XVG_FILE_EXTENSIONS
           
static java.lang.String[] XVG_MIME_TYPES
           
 
Constructor Summary
XMLInputHandler()
           
 
Method Summary
 boolean accept(java.io.File f)
          Returns true if the input file can be handled by the handler
 boolean accept(ParsedURL purl)
          Returns true if the input URI can be handled by the handler
 boolean accept(java.lang.String path)
          Return true if the resource with the given path can be handled.
protected  void checkAndPatch(Document doc)
          This method checks that the generated content is SVG.
protected  java.lang.String extractXSLProcessingInstruction(Document doc)
          Extracts the first XSL processing instruction from the input XML document.
 java.lang.String getDescription()
          Returns a description for this handler
 java.lang.String[] getHandledExtensions()
          Returns the list of file extensions handled by this handler
 java.lang.String[] getHandledMimeTypes()
          Returns the list of mime types handled by this handler.
 void handle(ParsedURL purl, JSVGViewerFrame svgViewerFrame)
          Handles the given input for the given JSVGViewerFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XVG_MIME_TYPES

public static final java.lang.String[] XVG_MIME_TYPES

XVG_FILE_EXTENSIONS

public static final java.lang.String[] XVG_FILE_EXTENSIONS

ERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTION

public static final java.lang.String ERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTION

ERROR_TRANSFORM_OUTPUT_NOT_SVG

public static final java.lang.String ERROR_TRANSFORM_OUTPUT_NOT_SVG

ERROR_TRANSFORM_PRODUCED_NO_CONTENT

public static final java.lang.String ERROR_TRANSFORM_PRODUCED_NO_CONTENT

ERROR_TRANSFORM_OUTPUT_WRONG_NS

public static final java.lang.String ERROR_TRANSFORM_OUTPUT_WRONG_NS

ERROR_RESULT_GENERATED_EXCEPTION

public static final java.lang.String ERROR_RESULT_GENERATED_EXCEPTION

XSL_PROCESSING_INSTRUCTION_TYPE

public static final java.lang.String XSL_PROCESSING_INSTRUCTION_TYPE

PSEUDO_ATTRIBUTE_TYPE

public static final java.lang.String PSEUDO_ATTRIBUTE_TYPE

PSEUDO_ATTRIBUTE_HREF

public static final java.lang.String PSEUDO_ATTRIBUTE_HREF
Constructor Detail

XMLInputHandler

public XMLInputHandler()
Method Detail

getHandledMimeTypes

public java.lang.String[] getHandledMimeTypes()
Returns the list of mime types handled by this handler.
Specified by:
getHandledMimeTypes in interface SquiggleInputHandler

getHandledExtensions

public java.lang.String[] getHandledExtensions()
Returns the list of file extensions handled by this handler
Specified by:
getHandledExtensions in interface SquiggleInputHandler

getDescription

public java.lang.String getDescription()
Returns a description for this handler
Specified by:
getDescription in interface SquiggleInputHandler

accept

public boolean accept(java.io.File f)
Returns true if the input file can be handled by the handler
Specified by:
accept in interface SquiggleInputHandler

accept

public boolean accept(ParsedURL purl)
Returns true if the input URI can be handled by the handler
Specified by:
accept in interface SquiggleInputHandler
Following copied from interface: org.apache.batik.apps.svgbrowser.SquiggleInputHandler
Parameters:
purl - URL describing the candidate input

accept

public boolean accept(java.lang.String path)
Return true if the resource with the given path can be handled.

handle

public void handle(ParsedURL purl,
                   JSVGViewerFrame svgViewerFrame)
            throws java.lang.Exception
Handles the given input for the given JSVGViewerFrame
Specified by:
handle in interface SquiggleInputHandler

checkAndPatch

protected void checkAndPatch(Document doc)
This method checks that the generated content is SVG. This method accounts for the fact that the root svg's first child is the result of the transform. It moves all its children under the root and sets the attributes

extractXSLProcessingInstruction

protected java.lang.String extractXSLProcessingInstruction(Document doc)
Extracts the first XSL processing instruction from the input XML document.


Copyright © 2002 Apache Software Foundation. All Rights Reserved.