Class XMLInputHandler

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

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.
  • Field Details

  • Constructor Details

    • XMLInputHandler

      public XMLInputHandler()
  • Method Details

    • getHandledMimeTypes

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

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

      public String getDescription()
      Returns a description for this handler
      Specified by:
      getDescription in interface SquiggleInputHandler
    • accept

      public boolean accept(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
      Parameters:
      purl - URL describing the candidate input
    • accept

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

      public void handle(ParsedURL purl, JSVGViewerFrame svgViewerFrame) throws Exception
      Handles the given input for the given JSVGViewerFrame
      Specified by:
      handle in interface SquiggleInputHandler
      Throws:
      Exception
    • 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.