Package 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
ASquiggleInputHandlerthat handles XSLT transformable XML documents. This implementation of theSquiggleInputHandlerclass 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.- Version:
- $Id: XMLInputHandler.java 1831635 2018-05-15 13:33:47Z ssteiner $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXMLInputHandler.DocumentURIResolverImplements the URIResolver interface so that relative urls used in transformations are resolved properly.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringERROR_NO_XML_STYLESHEET_PROCESSING_INSTRUCTIONstatic java.lang.StringERROR_RESULT_GENERATED_EXCEPTIONstatic java.lang.StringERROR_TRANSFORM_OUTPUT_NOT_SVGstatic java.lang.StringERROR_TRANSFORM_OUTPUT_WRONG_NSstatic java.lang.StringERROR_TRANSFORM_PRODUCED_NO_CONTENTstatic java.lang.StringPSEUDO_ATTRIBUTE_HREFstatic java.lang.StringPSEUDO_ATTRIBUTE_TYPEstatic java.lang.StringXSL_PROCESSING_INSTRUCTION_TYPEstatic java.lang.String[]XVG_FILE_EXTENSIONSstatic java.lang.String[]XVG_MIME_TYPES
-
Constructor Summary
Constructors Constructor Description XMLInputHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(java.io.File f)Returns true if the input file can be handled by the handlerbooleanaccept(java.lang.String path)Return true if the resource with the given path can be handled.booleanaccept(ParsedURL purl)Returns true if the input URI can be handled by the handlerprotected voidcheckAndPatch(org.w3c.dom.Document doc)This method checks that the generated content is SVG.protected java.lang.StringextractXSLProcessingInstruction(org.w3c.dom.Document doc)Extracts the first XSL processing instruction from the input XML document.java.lang.StringgetDescription()Returns a description for this handlerjava.lang.String[]getHandledExtensions()Returns the list of file extensions handled by this handlerjava.lang.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
-
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
- See Also:
- Constant Field Values
-
ERROR_TRANSFORM_OUTPUT_NOT_SVG
public static final java.lang.String ERROR_TRANSFORM_OUTPUT_NOT_SVG
- See Also:
- Constant Field Values
-
ERROR_TRANSFORM_PRODUCED_NO_CONTENT
public static final java.lang.String ERROR_TRANSFORM_PRODUCED_NO_CONTENT
- See Also:
- Constant Field Values
-
ERROR_TRANSFORM_OUTPUT_WRONG_NS
public static final java.lang.String ERROR_TRANSFORM_OUTPUT_WRONG_NS
- See Also:
- Constant Field Values
-
ERROR_RESULT_GENERATED_EXCEPTION
public static final java.lang.String ERROR_RESULT_GENERATED_EXCEPTION
- See Also:
- Constant Field Values
-
XSL_PROCESSING_INSTRUCTION_TYPE
public static final java.lang.String XSL_PROCESSING_INSTRUCTION_TYPE
- See Also:
- Constant Field Values
-
PSEUDO_ATTRIBUTE_TYPE
public static final java.lang.String PSEUDO_ATTRIBUTE_TYPE
- See Also:
- Constant Field Values
-
PSEUDO_ATTRIBUTE_HREF
public static final java.lang.String PSEUDO_ATTRIBUTE_HREF
- See Also:
- Constant Field Values
-
-
Method Detail
-
getHandledMimeTypes
public java.lang.String[] getHandledMimeTypes()
Returns the list of mime types handled by this handler.- Specified by:
getHandledMimeTypesin interfaceSquiggleInputHandler
-
getHandledExtensions
public java.lang.String[] getHandledExtensions()
Returns the list of file extensions handled by this handler- Specified by:
getHandledExtensionsin interfaceSquiggleInputHandler
-
getDescription
public java.lang.String getDescription()
Returns a description for this handler- Specified by:
getDescriptionin interfaceSquiggleInputHandler
-
accept
public boolean accept(java.io.File f)
Returns true if the input file can be handled by the handler- Specified by:
acceptin interfaceSquiggleInputHandler
-
accept
public boolean accept(ParsedURL purl)
Returns true if the input URI can be handled by the handler- Specified by:
acceptin interfaceSquiggleInputHandler- 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:
handlein interfaceSquiggleInputHandler- Throws:
java.lang.Exception
-
checkAndPatch
protected void checkAndPatch(org.w3c.dom.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(org.w3c.dom.Document doc)
Extracts the first XSL processing instruction from the input XML document.
-
-