2121import java .util .Map ;
2222
2323import javax .xml .transform .ErrorListener ;
24+ import javax .xml .transform .Source ;
2425import javax .xml .transform .Transformer ;
2526import javax .xml .transform .TransformerException ;
2627import javax .xml .transform .URIResolver ;
@@ -213,10 +214,10 @@ public final EValidity getSchematronValidity (@Nonnull final Node aXMLNode, @Nul
213214 }
214215
215216 @ Nullable
216- public final Document applySchematronValidation (@ Nonnull final Node aXMLNode , @ Nullable final String sBaseURI )
217- throws TransformerException
217+ public final Document applySchematronValidation (@ Nonnull final Source aSource )
218+ throws TransformerException
218219 {
219- ValueEnforcer .notNull (aXMLNode , "XMLNode " );
220+ ValueEnforcer .notNull (aSource , "Source " );
220221
221222 final ISchematronXSLTBasedProvider aXSLTProvider = getXSLTProvider ();
222223 if (aXSLTProvider == null || !aXSLTProvider .isValidSchematron ())
@@ -231,7 +232,7 @@ public final Document applySchematronValidation (@Nonnull final Node aXMLNode, @
231232 LOGGER .info ("Created XSLT document: " + XMLWriter .getNodeAsString (aXSLTProvider .getXSLTDocument ()));
232233
233234 LOGGER .info ("Applying Schematron XSLT on XML instance" +
234- (StringHelper .isNotEmpty (sBaseURI ) ? " with base URI '" + sBaseURI + "'" : "" ));
235+ (StringHelper .isNotEmpty (aSource . getSystemId ()) ? " with base URI '" + aSource . getSystemId () + "'" : "" ));
235236
236237 // Create result document
237238 final Document ret = XMLFactory .newDocument ();
@@ -264,11 +265,7 @@ public final Document applySchematronValidation (@Nonnull final Node aXMLNode, @
264265 LOGGER .debug ("Applying Schematron XSLT on XML [start]" );
265266
266267 // Do the main transformation
267- {
268- final DOMSource aSource = new DOMSource (aXMLNode );
269- aSource .setSystemId (sBaseURI );
270- aTransformer .transform (aSource , new DOMResult (ret ));
271- }
268+ aTransformer .transform (aSource , new DOMResult (ret ));
272269
273270 if (LOGGER .isDebugEnabled ())
274271 LOGGER .debug ("Applying Schematron XSLT on XML [end]" );
@@ -280,6 +277,13 @@ public final Document applySchematronValidation (@Nonnull final Node aXMLNode, @
280277 return ret ;
281278 }
282279
280+ @ Nullable
281+ public Document applySchematronValidation (@ Nonnull Node aXMLNode , @ Nullable String sBaseURI ) throws Exception {
282+ final DOMSource aSource = new DOMSource (aXMLNode );
283+ aSource .setSystemId (sBaseURI );
284+ return applySchematronValidation (aSource );
285+ }
286+
283287 @ Nullable
284288 public SchematronOutputType applySchematronValidationToSVRL (@ Nonnull final Node aXMLSource ,
285289 @ Nullable final String sBaseURI ) throws Exception
0 commit comments