Class PSReader
java.lang.Object
com.helger.schematron.pure.exchange.PSReader
Utility class for reading all Schematron elements from a resource.
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionPSReader(com.helger.commons.io.resource.IReadableResource aResource) Constructor without an error handlerPSReader(com.helger.commons.io.resource.IReadableResource aResource, IPSErrorHandler aErrorHandler, EntityResolver aEntityResolver) Constructor with an error handler -
Method Summary
Modifier and TypeMethodDescriptionfinal IPSErrorHandlerfinal com.helger.commons.io.resource.IReadableResourcefinal booleanbooleanisValidSchematronNS(String sNamespaceURI) readActiveFromXML(com.helger.xml.microdom.IMicroElement eActive) Read an <active> elementreadAssertReportFromXML(com.helger.xml.microdom.IMicroElement eAssertReport) Read an <assert> or a <report> elementreadDiagnosticFromXML(com.helger.xml.microdom.IMicroElement eDiagnostic) Read a <diagnostic> elementreadDiagnosticsFromXML(com.helger.xml.microdom.IMicroElement eDiagnostics) Read a <diagnostics> elementreadDirFromXML(com.helger.xml.microdom.IMicroElement eDir) Read a <dir> elementreadEmphFromXML(com.helger.xml.microdom.IMicroElement eEmph) Read an <emph> elementreadExtendsFromXML(com.helger.xml.microdom.IMicroElement eExtends) Read an <extends> elementreadIncludeFromXML(com.helger.xml.microdom.IMicroElement eInclude) Read an <include> elementreadLetFromXML(com.helger.xml.microdom.IMicroElement eLet) Read a <let> elementreadNameFromXML(com.helger.xml.microdom.IMicroElement eName) Read a <name> elementreadNSFromXML(com.helger.xml.microdom.IMicroElement eNS) Read a <ns> elementreadParamFromXML(com.helger.xml.microdom.IMicroElement eParam) Read a <param> elementreadPatternFromXML(com.helger.xml.microdom.IMicroElement ePattern) Read a <pattern> elementreadPFromXML(com.helger.xml.microdom.IMicroElement eP) Read a <p> elementreadPhaseFromXML(com.helger.xml.microdom.IMicroElement ePhase) Read a <phase> elementreadRuleFromXML(com.helger.xml.microdom.IMicroElement eRule) Read a <rule> elementRead the schema from the resource supplied in the constructor.readSchemaFromXML(com.helger.xml.microdom.IMicroElement eSchema) Parse the Schematron into a pure Java object.readSpanFromXML(com.helger.xml.microdom.IMicroElement eSpan) Read a <span> elementreadTitleFromXML(com.helger.xml.microdom.IMicroElement eTitle) Read a <title> elementreadValueOfFromXML(com.helger.xml.microdom.IMicroElement eValueOf) Read a <value-of> elementfinal PSReadersetLenient(boolean bLenient) Allow or disallow the support for old namespace prefix.toString()
-
Constructor Details
-
PSReader
Constructor without an error handler- Parameters:
aResource- The resource to read the Schematron from. May not benull.
-
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 benull.aErrorHandler- The error handler to use. May benull. If the error handler isnullaLoggingPSErrorHandleris automatically created and used.aEntityResolver- The XML entity resolver to be used. May benull.- Since:
- 4.1.1
-
-
Method Details
-
getResource
- Returns:
- The resource from which the Schematron schema is read. Never
null.
-
getErrorHandler
- Returns:
- The error handler used. If no error handler was passed in the
constructor, than a
LoggingPSErrorHandleris automatically used.
-
isLenient
public final boolean isLenient()- Returns:
trueif the old Schematron namespace is supported,falseif not. Default isCSchematron.DEFAULT_ALLOW_DEPRECATED_NAMESPACES.- Since:
- 5.4.1
-
setLenient
Allow or disallow the support for old namespace prefix. By default this is deprecated.- Parameters:
bLenient-trueto enable support for old namespace URIs,falseto disallow it.- Returns:
- this for chaining
- Since:
- 5.4.1
-
readActiveFromXML
Read an <active> element- Parameters:
eActive- The source micro element. Nevernull.- 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. Nevernull.- 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. Nevernull.- 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. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readDirFromXML
Read a <dir> element- Parameters:
eDir- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readEmphFromXML
Read an <emph> element- Parameters:
eEmph- The source micro element. Nevernull.- 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. Nevernull.- 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. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readLetFromXML
Read a <let> element- Parameters:
eLet- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readNameFromXML
Read a <name> element- Parameters:
eName- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readNSFromXML
Read a <ns> element- Parameters:
eNS- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readPFromXML
Read a <p> element- Parameters:
eP- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readParamFromXML
Read a <param> element- Parameters:
eParam- The source micro element. Nevernull.- 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. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readPhaseFromXML
Read a <phase> element- Parameters:
ePhase- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readRuleFromXML
Read a <rule> element- Parameters:
eRule- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
isValidSchematronNS
-
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 benull.- Returns:
- The created
PSSchemaobject ornullin case ofnulldocument or a fatal error. - Throws:
SchematronReadException- If reading fails
-
readSpanFromXML
Read a <span> element- Parameters:
eSpan- The source micro element. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readTitleFromXML
Read a <title> element- Parameters:
eTitle- The source micro element. Nevernull.- 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. Nevernull.- Returns:
- The created domain object. May not be
null.
-
readSchema
Read the schema from the resource supplied in the constructor. First all includes are resolved and thanreadSchemaFromXML(IMicroElement)is called.- Returns:
- The read
PSSchema. - Throws:
SchematronReadException- If reading fails
-
toString
-