org.apache.batik.apps.svgbrowser

Class XMLInputHandler

public class XMLInputHandler extends Object implements SquiggleInputHandler

A SquiggleInputHandler that handles XSLT transformable XML documents. 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.
Nested Class Summary
classXMLInputHandler.DocumentURIResolver
Implements the URIResolver interface so that relative urls used in transformations are resolved properly.
Field Summary
static StringERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTION
static StringERROR_RESULT_GENERATED_EXCEPTION
static StringERROR_TRANSFORM_OUTPUT_NOT_SVG
static StringERROR_TRANSFORM_OUTPUT_WRONG_NS
static StringERROR_TRANSFORM_PRODUCED_NO_CONTENT
static StringPSEUDO_ATTRIBUTE_HREF
static StringPSEUDO_ATTRIBUTE_TYPE
static StringXSL_PROCESSING_INSTRUCTION_TYPE
static String[]XVG_FILE_EXTENSIONS
static String[]XVG_MIME_TYPES
Method Summary
booleanaccept(File f)
Returns true if the input file can be handled by the handler
booleanaccept(ParsedURL purl)
Returns true if the input URI can be handled by the handler
booleanaccept(String path)
Return true if the resource with the given path can be handled.
protected voidcheckAndPatch(Document doc)
This method checks that the generated content is SVG.
protected StringextractXSLProcessingInstruction(Document doc)
Extracts the first XSL processing instruction from the input XML document.
StringgetDescription()
Returns a description for this handler
String[]getHandledExtensions()
Returns the list of file extensions handled by this handler
String[]getHandledMimeTypes()
Returns the list of mime types handled by this handler.
voidhandle(ParsedURL purl, JSVGViewerFrame svgViewerFrame)
Handles the given input for the given JSVGViewerFrame

Field Detail

ERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTION

public static final String ERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTION

ERROR_RESULT_GENERATED_EXCEPTION

public static final String ERROR_RESULT_GENERATED_EXCEPTION

ERROR_TRANSFORM_OUTPUT_NOT_SVG

public static final String ERROR_TRANSFORM_OUTPUT_NOT_SVG

ERROR_TRANSFORM_OUTPUT_WRONG_NS

public static final String ERROR_TRANSFORM_OUTPUT_WRONG_NS

ERROR_TRANSFORM_PRODUCED_NO_CONTENT

public static final String ERROR_TRANSFORM_PRODUCED_NO_CONTENT

PSEUDO_ATTRIBUTE_HREF

public static final String PSEUDO_ATTRIBUTE_HREF

PSEUDO_ATTRIBUTE_TYPE

public static final String PSEUDO_ATTRIBUTE_TYPE

XSL_PROCESSING_INSTRUCTION_TYPE

public static final String XSL_PROCESSING_INSTRUCTION_TYPE

XVG_FILE_EXTENSIONS

public static final String[] XVG_FILE_EXTENSIONS

XVG_MIME_TYPES

public static final String[] XVG_MIME_TYPES

Method Detail

accept

public boolean accept(File f)
Returns true if the input file can be handled by the handler

accept

public boolean accept(ParsedURL purl)
Returns true if the input URI can be handled by the handler

accept

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

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 String extractXSLProcessingInstruction(Document doc)
Extracts the first XSL processing instruction from the input XML document.

getDescription

public String getDescription()
Returns a description for this handler

getHandledExtensions

public String[] getHandledExtensions()
Returns the list of file extensions handled by this handler

getHandledMimeTypes

public String[] getHandledMimeTypes()
Returns the list of mime types handled by this handler.

handle

public void handle(ParsedURL purl, JSVGViewerFrame svgViewerFrame)
Handles the given input for the given JSVGViewerFrame
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.