Skip to content

Commit

Permalink
Made resolver customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Dec 18, 2024
1 parent 24f363b commit 3e60ebb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public static IMicroDocument getWithResolvedSchematronIncludes (@Nonnull final I
return getWithResolvedSchematronIncludes (aResource,
null,
aErrorHandler,
(ISchematronIncludeResolver) null,
CSchematron.DEFAULT_ALLOW_DEPRECATED_NAMESPACES);
}

Expand All @@ -367,6 +368,7 @@ public static IMicroDocument getWithResolvedSchematronIncludes (@Nonnull final I
return getWithResolvedSchematronIncludes (aResource,
aSettings,
aErrorHandler,
(ISchematronIncludeResolver) null,
CSchematron.DEFAULT_ALLOW_DEPRECATED_NAMESPACES);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.helger.schematron.pure.model.*;
import com.helger.schematron.pure.model.PSDir.EDirValue;
import com.helger.schematron.pure.model.PSRichGroup.ESpace;
import com.helger.schematron.resolve.ISchematronIncludeResolver;
import com.helger.xml.microdom.IMicroDocument;
import com.helger.xml.microdom.IMicroElement;
import com.helger.xml.microdom.serialize.MicroWriter;
Expand All @@ -54,6 +55,7 @@ public class PSReader

private final IReadableResource m_aResource;
private final IPSErrorHandler m_aErrorHandler;
private ISchematronIncludeResolver m_aSchematronIncludeResolver;
private final EntityResolver m_aEntityResolver;
private boolean m_bLenient = CSchematron.DEFAULT_ALLOW_DEPRECATED_NAMESPACES;

Expand Down Expand Up @@ -153,6 +155,31 @@ public final PSReader setLenient (final boolean bLenient)
return this;
}

/**
* @return The custom Schematron include resolver. May be <code>null</code>.
* @since 8.0.5
*/
@Nullable
public final ISchematronIncludeResolver getSchematronIncludeResolver ()
{
return m_aSchematronIncludeResolver;
}

/**
* Set the customer schematron include resolver to be used.
*
* @param aSchematronIncludeResolver
* The resolver to be used. May be <code>null</code>.
* @return this for chaining
* @since 8.0.5
*/
@Nonnull
public final PSReader setSchematronIncludeResolver (@Nullable final ISchematronIncludeResolver aSchematronIncludeResolver)
{
m_aSchematronIncludeResolver = aSchematronIncludeResolver;
return this;
}

/**
* Utility method to get a real attribute value, by trimming spaces, if the
* value is non-<code>null</code>.
Expand Down Expand Up @@ -1210,6 +1237,7 @@ public PSSchema readSchema () throws SchematronReadException
final IMicroDocument aDoc = SchematronHelper.getWithResolvedSchematronIncludes (m_aResource,
aSettings,
m_aErrorHandler,
m_aSchematronIncludeResolver,
m_bLenient);
if (aDoc == null || aDoc.getDocumentElement () == null)
throw new SchematronReadException (m_aResource,
Expand Down

0 comments on commit 3e60ebb

Please sign in to comment.