Class PSReader

java.lang.Object
com.helger.schematron.pure.exchange.PSReader

@Immutable public class PSReader extends Object
Utility class for reading all Schematron elements from a resource.
Author:
Philip Helger
  • Constructor Details

    • PSReader

      public PSReader(@Nonnull com.helger.commons.io.resource.IReadableResource aResource)
      Constructor without an error handler
      Parameters:
      aResource - The resource to read the Schematron from. May not be null.
    • PSReader

      public PSReader(@Nonnull com.helger.commons.io.resource.IReadableResource aResource, @Nullable IPSErrorHandler aErrorHandler, @Nullable EntityResolver aEntityResolver)
      Constructor with an error handler
      Parameters:
      aResource - The resource to read the Schematron from. May not be null.
      aErrorHandler - The error handler to use. May be null. If the error handler is null a LoggingPSErrorHandler is automatically created and used.
      aEntityResolver - The XML entity resolver to be used. May be null.
      Since:
      4.1.1
  • Method Details

    • getResource

      @Nonnull public final com.helger.commons.io.resource.IReadableResource getResource()
      Returns:
      The resource from which the Schematron schema is read. Never null.
    • getErrorHandler

      @Nonnull public final IPSErrorHandler getErrorHandler()
      Returns:
      The error handler used. If no error handler was passed in the constructor, than a LoggingPSErrorHandler is automatically used.
    • isLenient

      public final boolean isLenient()
      Returns:
      true if the old Schematron namespace is supported, false if not. Default is CSchematron.DEFAULT_ALLOW_DEPRECATED_NAMESPACES.
      Since:
      5.4.1
    • setLenient

      @Nonnull public final PSReader setLenient(boolean bLenient)
      Allow or disallow the support for old namespace prefix. By default this is deprecated.
      Parameters:
      bLenient - true to enable support for old namespace URIs, false to disallow it.
      Returns:
      this for chaining
      Since:
      5.4.1
    • readActiveFromXML

      @Nonnull public PSActive readActiveFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eActive)
      Read an <active> element
      Parameters:
      eActive - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readAssertReportFromXML

      @Nonnull public PSAssertReport readAssertReportFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eAssertReport)
      Read an <assert> or a <report> element
      Parameters:
      eAssertReport - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readDiagnosticFromXML

      @Nonnull public PSDiagnostic readDiagnosticFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eDiagnostic)
      Read a <diagnostic> element
      Parameters:
      eDiagnostic - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readDiagnosticsFromXML

      @Nonnull public PSDiagnostics readDiagnosticsFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eDiagnostics)
      Read a <diagnostics> element
      Parameters:
      eDiagnostics - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readDirFromXML

      @Nonnull public PSDir readDirFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eDir)
      Read a <dir> element
      Parameters:
      eDir - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readEmphFromXML

      @Nonnull public PSEmph readEmphFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eEmph)
      Read an <emph> element
      Parameters:
      eEmph - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readExtendsFromXML

      @Nonnull public PSExtends readExtendsFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eExtends)
      Read an <extends> element
      Parameters:
      eExtends - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readIncludeFromXML

      @Nonnull public PSInclude readIncludeFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eInclude)
      Read an <include> element
      Parameters:
      eInclude - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readLetFromXML

      @Nonnull public PSLet readLetFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eLet)
      Read a <let> element
      Parameters:
      eLet - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readNameFromXML

      @Nonnull public PSName readNameFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eName)
      Read a <name> element
      Parameters:
      eName - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readNSFromXML

      @Nonnull public PSNS readNSFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eNS)
      Read a <ns> element
      Parameters:
      eNS - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readPFromXML

      @Nonnull public PSP readPFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eP)
      Read a <p> element
      Parameters:
      eP - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readParamFromXML

      @Nonnull public PSParam readParamFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eParam)
      Read a <param> element
      Parameters:
      eParam - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readPatternFromXML

      @Nonnull public PSPattern readPatternFromXML(@Nonnull com.helger.xml.microdom.IMicroElement ePattern)
      Read a <pattern> element
      Parameters:
      ePattern - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readPhaseFromXML

      @Nonnull public PSPhase readPhaseFromXML(@Nonnull com.helger.xml.microdom.IMicroElement ePhase)
      Read a <phase> element
      Parameters:
      ePhase - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readRuleFromXML

      @Nonnull public PSRule readRuleFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eRule)
      Read a <rule> element
      Parameters:
      eRule - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • isValidSchematronNS

      public boolean isValidSchematronNS(@Nullable String sNamespaceURI)
    • readSchemaFromXML

      @Nonnull public PSSchema readSchemaFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eSchema) throws SchematronReadException
      Parse the Schematron into a pure Java object. This method makes no assumptions on the validity of the document!
      Parameters:
      eSchema - The XML element to use. May not be null.
      Returns:
      The created PSSchema object or null in case of null document or a fatal error.
      Throws:
      SchematronReadException - If reading fails
    • readSpanFromXML

      @Nonnull public PSSpan readSpanFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eSpan)
      Read a <span> element
      Parameters:
      eSpan - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readTitleFromXML

      @Nonnull public PSTitle readTitleFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eTitle)
      Read a <title> element
      Parameters:
      eTitle - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readValueOfFromXML

      @Nonnull public PSValueOf readValueOfFromXML(@Nonnull com.helger.xml.microdom.IMicroElement eValueOf)
      Read a <value-of> element
      Parameters:
      eValueOf - The source micro element. Never null.
      Returns:
      The created domain object. May not be null.
    • readSchema

      @Nonnull public PSSchema readSchema() throws SchematronReadException
      Read the schema from the resource supplied in the constructor. First all includes are resolved and than readSchemaFromXML(IMicroElement) is called.
      Returns:
      The read PSSchema.
      Throws:
      SchematronReadException - If reading fails
    • toString

      public String toString()
      Overrides:
      toString in class Object