Class ResourceBuilder

java.lang.Object
de.wwu.scdh.annotation.selection.resource.ResourceBuilder

public class ResourceBuilder extends Object
A ResourceBuilder makes Resource from a URI.
  • Field Details

  • Constructor Details

    • ResourceBuilder

      public ResourceBuilder(net.sf.saxon.s9api.Processor processor)
      Makes a new ResourceBuilder instance.
  • Method Details

    • parseResource

      public Resource<?> parseResource(URI resource, ResourceBuilder.Parser parser) throws ResourceException
      Parses the contents of a given URI with a given ResourceBuilder.Parser.
      Throws:
      ResourceException
    • parseResource

      public Resource<?> parseResource(URI resource, InputStream inputStream, String systemId, ResourceBuilder.Parser parser) throws ResourceException
      Parses the contents of a given URI with a given ResourceBuilder.Parser.
      Throws:
      ResourceException
    • mapWithXslTransformation

      public static MappedDOMResource mapWithXslTransformation(URI imageUri, DOMResource preimage, net.sf.saxon.s9api.Xslt30Transformer transformer, Class<? extends Point> imagePointClass) throws ResourceException
      Derives a MappedDOMResource from a preimage and an XSLT stylesheet.

      Note: When a saxon config file with XSLT packages is used (by reading it when constructing the Processor), only compiling the right XSLT tracing package is not enough. Transforming the config file and changing the resourceLocation is required.

      processorFromModifiedConfig(Source) has a solution.

      Parameters:
      imageUri - - the URI of the image
      preimage - - the resource deriving from
      transformer - - an Xslt30Transformer to derive the image with
      imagePointClass - - the class of the point used for the image, or null for concluding from the stylesheet's default output method
      Throws:
      ResourceException
    • mapWithXsltTracePackage

      public static MappedDOMResource mapWithXsltTracePackage(DOMResource preimage, URI stylesheet, InputStream traceStream, String traceSystemId, Class<? extends Point> imagePointClass) throws ResourceException
      Derives a MappedDOMResource from a preimage and an XSLT stylesheet.

      Note: When a saxon config file with XSLT packages is used (by reading it when constructing the Processor), only compiling the right XSLT tracing package is not enough. Transforming the config file and changing the resourceLocation is required.

      processorFromModifiedConfig(Source) has a solution.

      Parameters:
      preimage - - the resource deriving from
      stylesheet - - URI of the XSLT stylesheet used for deriving
      traceStream - - an input stream made of the the XSLT package for adding the mapping information
      traceSystemId - - the path of the XSLT package for adding the mapping information
      imagePointClass - - the class of the point used for the image, or null for concluding from the stylesheet's default output method
      Throws:
      ResourceException
    • mapWithXsltTracePackage

      public static MappedDOMResource mapWithXsltTracePackage(DOMResource preimage, URI stylesheet, URI tracePkg, Class<? extends Point> imagePointClass) throws ResourceException
      Makes a MappedDOMResource from a preimage and an XSLT stylesheet.
      Parameters:
      preimage - - the resource deriving from
      stylesheet - - URI of the XSLT stylesheet used for deriving
      tracePkg - - URI of the the XSLT package for adding the mapping information
      imagePointClass - - the class of the point used for the image, or null for concluding from the stylesheet's default output method
      Throws:
      ResourceException
    • mapWithXsltTracePackage

      public static MappedDOMResource mapWithXsltTracePackage(DOMResource preimage, URI stylesheet, Class<? extends Point> imagePointClass) throws ResourceException
      Makes a MappedDOMResource from a preimage and an XSLT stylesheet. This method uses the internal XSLT package for adding mapping information.
      Parameters:
      preimage - - the resource deriving from
      stylesheet - - URI of the XSLT stylesheet used for deriving
      imagePointClass - - the class of the point used for the image, or null for concluding from the stylesheet's default output method
      Throws:
      ResourceException
    • pointerClassFromOutputMethod

      public static Class<? extends Point> pointerClassFromOutputMethod(String method) throws ResourceException
      Returns the point class for the output method, i.e. the serialization method. In XSLT, the output method is set by xsl:output/@method.
      Throws:
      ResourceException
    • pointerClassFromOutputMethod

      public static Class<? extends Point> pointerClassFromOutputMethod(net.sf.saxon.s9api.Xslt30Transformer transformer) throws ResourceException
      Gets the default output method from the stylesheet and returns the point class for it. The output method is set by xsl:output/@method or is xml if this declaration is missing.
      Throws:
      ResourceException
    • processorFromModifiedConfig

      public static net.sf.saxon.s9api.Processor processorFromModifiedConfig(Source config) throws ResourceException
      Returns a Processor made with the Saxon config given in as the second argument after modifying it following the internal requirements for the tracing package.
      Parameters:
      config - - a saxon config file as Source
      Throws:
      ResourceException
    • compileTracingPackage

      public static net.sf.saxon.s9api.XsltPackage compileTracingPackage(net.sf.saxon.s9api.XsltCompiler compiler, ResourceBuilder.OutputMethod method) throws net.sf.saxon.s9api.SaxonApiException, ResourceException
      This compiles the XSLT tracing library for the given output method.
      Parameters:
      compiler - - an XsltCompiler for compiling the tracing library
      method - - the output method xsl:output/@method of the stylesheet
      Returns:
      the compiled package
      Throws:
      net.sf.saxon.s9api.SaxonApiException - when a compilation error occurred
      ResourceException - e.g. when the requested output method is not supported