mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
some cleanup
This commit is contained in:
parent
1a001a1af4
commit
7dc62012a6
22 changed files with 144 additions and 50 deletions
|
|
@ -94,16 +94,5 @@ public class RelativeUriResolver implements URIResolver {
|
|||
}
|
||||
|
||||
|
||||
public Reader resolve(final URI absoluteURI, final String encoding, final Configuration config) throws XPathException {
|
||||
if (isUnderBaseUri(absoluteURI)) {
|
||||
try {
|
||||
return new InputStreamReader(absoluteURI.toURL().openStream(), encoding);
|
||||
} catch (final IOException e) {
|
||||
throw new IllegalStateException(String.format("Can not resolve required %s", absoluteURI), e);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException(String.format(
|
||||
"The resolved transformation artifact %s is not within the configured repository %s", absoluteURI, this.baseUri));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package de.kosit.validationtool.impl.xml;
|
||||
|
||||
public class RemoteResolvingStrategy extends StrictLocalResolvingStrategy {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,7 +10,9 @@ import javax.xml.validation.Validator;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
*
|
||||
* This is a slightly more open implementation that allows resolving artifacts from local filesystems. Your are not
|
||||
* bound to a specific 'repository'. But your validation artifacts (schema, xsl, etc.) must be available locally. This
|
||||
* implementation does not allow loading from http sources
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
|
|
@ -18,16 +20,23 @@ import lombok.extern.slf4j.Slf4j;
|
|||
public class StrictLocalResolvingStrategy extends StrictRelativeResolvingStrategy {
|
||||
|
||||
/**
|
||||
* e.g. don't allow any scheme
|
||||
* Allow loading schema files from any local location.
|
||||
*
|
||||
* @return a configured {@link SchemaFactory}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public SchemaFactory createSchemaFactory() {
|
||||
final SchemaFactory schemaFactory = super.createSchemaFactory();
|
||||
allowExternalSchema(schemaFactory, "file", "jar");
|
||||
allowExternalSchema(schemaFactory, "file");
|
||||
return schemaFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default resolver is able to resolve locally and relative.
|
||||
*
|
||||
* @param repository the repository is not used by this strategy
|
||||
* @return null!
|
||||
*/
|
||||
@Override
|
||||
public URIResolver createResolver(final URI repository) {
|
||||
// intentionally return 'null', since all resolving is configured with the other objects
|
||||
|
|
@ -37,7 +46,7 @@ public class StrictLocalResolvingStrategy extends StrictRelativeResolvingStrateg
|
|||
@Override
|
||||
public Validator createValidator(final Schema schema) {
|
||||
final Validator validator = super.createValidator(schema);
|
||||
allowExternalSchema(validator, "file", "jar");
|
||||
allowExternalSchema(validator, "file");
|
||||
return validator;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ public class StrictRelativeResolvingStrategy extends BaseResolvingStrategy {
|
|||
processor.setConfigurationProperty(FeatureKeys.XML_PARSER_FEATURE + encode(FEATURE_SECURE_PROCESSING), true);
|
||||
processor.setConfigurationProperty(FeatureKeys.XML_PARSER_FEATURE + encode(DISSALLOW_DOCTYPE_DECL_FEATURE), true);
|
||||
processor.setConfigurationProperty(FeatureKeys.XML_PARSER_FEATURE + encode(LOAD_EXTERNAL_DTD_FEATURE), false);
|
||||
processor.setConfigurationProperty(FeatureKeys.XML_PARSER_FEATURE + encode(XMLConstants.ACCESS_EXTERNAL_DTD), false);
|
||||
return processor;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue