本文整理汇总了Java中org.oclc.purl.dsdl.svrl.SchematronOutputType类的典型用法代码示例。如果您正苦于以下问题:Java SchematronOutputType类的具体用法?Java SchematronOutputType怎么用?Java SchematronOutputType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SchematronOutputType类属于org.oclc.purl.dsdl.svrl包,在下文中一共展示了SchematronOutputType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStart
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Override
public void onStart (@Nonnull final PSSchema aSchema,
@Nullable final PSPhase aActivePhase,
@Nullable final String sBaseURI) throws SchematronValidationException
{
final SchematronOutputType aSchematronOutput = new SchematronOutputType ();
if (aActivePhase != null)
aSchematronOutput.setPhase (aActivePhase.getID ());
aSchematronOutput.setSchemaVersion (aSchema.getSchemaVersion ());
aSchematronOutput.setTitle (_getTitleAsString (aSchema.getTitle ()));
// Add namespace prefixes
for (final Map.Entry <String, String> aEntry : aSchema.getAsNamespaceContext ()
.getPrefixToNamespaceURIMap ()
.entrySet ())
{
final NsPrefixInAttributeValues aNsPrefix = new NsPrefixInAttributeValues ();
aNsPrefix.setPrefix (aEntry.getKey ());
aNsPrefix.setUri (aEntry.getValue ());
aSchematronOutput.getNsPrefixInAttributeValues ().add (aNsPrefix);
}
m_aSchematronOutput = aSchematronOutput;
m_aSchema = aSchema;
m_sBaseURI = sBaseURI;
}
示例2: getAllFailedAssertionsMoreOrEqualSevereThan
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
/**
* Get a list of all failed assertions in a given schematron output, with an
* error level equally or more severe than the passed error level.
*
* @param aSchematronOutput
* The schematron output to be used. May not be <code>null</code>.
* @param aErrorLevel
* Minimum error level to be queried
* @return A non-<code>null</code> list with all failed assertions.
*/
@Nonnull
@ReturnsMutableCopy
public static ICommonsList <SVRLFailedAssert> getAllFailedAssertionsMoreOrEqualSevereThan (@Nonnull final SchematronOutputType aSchematronOutput,
@Nonnull final IErrorLevel aErrorLevel)
{
final ICommonsList <SVRLFailedAssert> ret = new CommonsArrayList <> ();
for (final Object aObj : aSchematronOutput.getActivePatternAndFiredRuleAndFailedAssert ())
if (aObj instanceof FailedAssert)
{
final SVRLFailedAssert aFA = new SVRLFailedAssert ((FailedAssert) aObj);
if (aFA.getFlag ().isGE (aErrorLevel))
ret.add (aFA);
}
return ret;
}
示例3: getAllSuccessfulReportsMoreOrEqualSevereThan
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
/**
* Get a list of all successful reports in a given schematron output, with an
* error level equally or more severe than the passed error level.
*
* @param aSchematronOutput
* The schematron output to be used. May not be <code>null</code>.
* @param aErrorLevel
* Minimum error level to be queried
* @return A non-<code>null</code> list with all successful reports.
*/
@Nonnull
@ReturnsMutableCopy
public static ICommonsList <SVRLSuccessfulReport> getAllSuccessfulReportsMoreOrEqualSevereThan (@Nonnull final SchematronOutputType aSchematronOutput,
@Nonnull final IErrorLevel aErrorLevel)
{
final ICommonsList <SVRLSuccessfulReport> ret = new CommonsArrayList <> ();
for (final Object aObj : aSchematronOutput.getActivePatternAndFiredRuleAndFailedAssert ())
if (aObj instanceof SuccessfulReport)
{
final SVRLSuccessfulReport aFA = new SVRLSuccessfulReport ((SuccessfulReport) aObj);
if (aFA.getFlag ().isGE (aErrorLevel))
ret.add (aFA);
}
return ret;
}
示例4: applySchematron
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
/**
* Apply the passed schematron on the passed XML resource using a custom error
* handler.
*
* @param aSchematron
* The Schematron resource. May not be <code>null</code>.
* @param aXML
* The XML resource. May not be <code>null</code>.
* @return <code>null</code> if either the Schematron or the XML could not be
* read.
* @throws IllegalStateException
* if the processing throws an unexpected exception.
*/
@Nullable
public static SchematronOutputType applySchematron (@Nonnull final ISchematronResource aSchematron,
@Nonnull final IReadableResource aXML)
{
ValueEnforcer.notNull (aSchematron, "SchematronResource");
ValueEnforcer.notNull (aXML, "XMLSource");
try
{
// Apply Schematron on XML
return aSchematron.applySchematronValidationToSVRL (aXML);
}
catch (final Exception ex)
{
throw new IllegalArgumentException ("Failed to apply Schematron " +
aSchematron.getID () +
" onto XML resource " +
aXML.getResourceID (),
ex);
}
}
示例5: validateAndProduceSVRL
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
public static void validateAndProduceSVRL (@Nonnull final File aSchematron, final File aXML) throws Exception
{
// Create the custom parameters
final ICommonsMap <String, Object> aCustomParameters = new CommonsHashMap <> ();
aCustomParameters.put ("xyz", "mobile");
aCustomParameters.put ("expected", "");
final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile (aSchematron);
// Assign custom parameters
aSCH.setParameters (aCustomParameters);
if (false)
System.out.println (XMLWriter.getNodeAsString (aSCH.getXSLTProvider ().getXSLTDocument ()));
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL (new FileSystemResource (aXML));
assertNotNull (aSVRL);
if (false)
System.out.println (new SVRLMarshaller ().getAsString (aSVRL));
}
示例6: validateAndProduceSVRL
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@SuppressFBWarnings ("BC_IMPOSSIBLE_INSTANCEOF")
public static void validateAndProduceSVRL (final File schematron, final File xml) throws Exception
{
final IReadableResource aSchematron = new FileSystemResource (schematron.getAbsoluteFile ());
final IReadableResource anXMLSource = new FileSystemResource (xml.getAbsoluteFile ());
final AbstractSchematronResource aSCH = new SchematronResourceSCH (aSchematron);
if (aSCH instanceof SchematronResourcePure)
((SchematronResourcePure) aSCH).setErrorHandler (new LoggingPSErrorHandler ());
else
System.out.println (XMLWriter.getNodeAsString (((SchematronResourceSCH) aSCH).getXSLTProvider ()
.getXSLTDocument ()));
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL (anXMLSource);
assertNotNull (aSVRL);
if (false)
System.out.println (new SVRLMarshaller ().getAsString (aSVRL));
}
示例7: validateAndProduceSVRL
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
public static void validateAndProduceSVRL (@Nonnull final File aSchematron, final File aXML) throws Exception
{
final PSSchema aSchema = new PSReader (new FileSystemResource (aSchematron)).readSchema ();
final PSPreprocessor aPreprocessor = new PSPreprocessor (PSXPathQueryBinding.getInstance ());
final PSSchema aPreprocessedSchema = aPreprocessor.getAsPreprocessedSchema (aSchema);
final String sSCH = new PSWriter (new PSWriterSettings ().setXMLWriterSettings (new XMLWriterSettings ())).getXMLString (aPreprocessedSchema);
if (false)
System.out.println (sSCH);
final SchematronResourceSCH aSCH = new SchematronResourceSCH (new ReadableResourceString (sSCH,
StandardCharsets.UTF_8));
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL (new FileSystemResource (aXML));
assertNotNull (aSVRL);
if (false)
System.out.println (new SVRLMarshaller ().getAsString (aSVRL));
}
示例8: validateXmlUsingSchematron
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Nullable
static SchematronOutputType validateXmlUsingSchematron (@Nonnull final IReadableResource aRes)
{
SchematronOutputType ob = null;
// Must use the XSLT based version, because of "key" usage
final ISchematronResource aResSCH = new SchematronResourcePure (new ClassPathResource ("issues/github29/pbs.sch"));
if (!aResSCH.isValidSchematron ())
throw new IllegalArgumentException ("Invalid Schematron!");
try
{
final Document aDoc = aResSCH.applySchematronValidation (new ResourceStreamSource (aRes));
if (aDoc != null)
{
final SVRLMarshaller marshaller = new SVRLMarshaller ();
ob = marshaller.read (aDoc);
}
}
catch (final Exception pE)
{
pE.printStackTrace ();
}
return ob;
}
示例9: testWriteValid
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Test
public void testWriteValid () throws Exception
{
final Document aDoc = SchematronResourceSCH.fromClassPath (VALID_SCHEMATRON)
.applySchematronValidation (new ClassPathResource (VALID_XMLINSTANCE));
assertNotNull (aDoc);
final SchematronOutputType aSO = new SVRLMarshaller ().read (aDoc);
// Create XML
final Document aDoc2 = new SVRLMarshaller ().getAsDocument (aSO);
assertNotNull (aDoc2);
assertEquals (CSVRL.SVRL_NAMESPACE_URI, aDoc2.getDocumentElement ().getNamespaceURI ());
// Create String
final String sDoc2 = new SVRLMarshaller ().getAsString (aSO);
assertTrue (StringHelper.hasText (sDoc2));
assertTrue (sDoc2.contains (CSVRL.SVRL_NAMESPACE_URI));
}
示例10: validateXMLSchematron
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
public static boolean validateXMLSchematron (@Nonnull final File schPath,
@Nonnull final EMode eMode,
@Nonnull final File xmlPath,
@Nullable final File svrlPath)
{
final FileSystemResource aXML = new FileSystemResource (xmlPath);
final FileSystemResource aSCH = new FileSystemResource (schPath);
// Use pure implementation or XSLT to do the conversion?
final ISchematronResource aSchematron = eMode == EMode.PURE ? new SchematronResourcePure (aSCH)
: eMode == EMode.XSLT ? new SchematronResourceXSLT (aSCH)
: new SchematronResourceSCH (aSCH);
final SchematronOutputType aSOT = SchematronHelper.applySchematron (aSchematron, aXML);
if (aSOT == null)
{
s_aLogger.info ("Schematron file " + aSchematron + " is malformed!");
return false;
}
// Write SVRL
if (svrlPath != null)
new SVRLMarshaller (false).write (aSOT, new FileSystemResource (svrlPath));
final ICommonsList <SVRLFailedAssert> aFailedAsserts = SVRLHelper.getAllFailedAssertions (aSOT);
if (aFailedAsserts.isNotEmpty ())
{
s_aLogger.info ("XML does not comply to Schematron!" +
(svrlPath != null ? " See SVRL for details: " + svrlPath : ""));
return false;
}
s_aLogger.info ("XML complies to Schematron!");
return true;
}
示例11: validateResource
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Override
public void validateResource(ValidationContext<IResource> theCtx) {
ISchematronResource sch = getSchematron(theCtx);
StreamSource source = new StreamSource(new StringReader(theCtx.getXmlEncodedResource()));
SchematronOutputType results = SchematronHelper.applySchematron(sch, source);
if (results == null) {
return;
}
IResourceErrorGroup errors = SchematronHelper.convertToResourceErrorGroup(results, theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName());
if (errors.getAllErrors().containsOnlySuccess()) {
return;
}
for (IResourceError next : errors.getAllErrors().getAllResourceErrors()) {
BaseIssue issue = theCtx.getOperationOutcome().addIssue();
switch (next.getErrorLevel()) {
case ERROR:
issue.getSeverityElement().setValue("error");
break;
case FATAL_ERROR:
issue.getSeverityElement().setValue("fatal");
break;
case WARN:
issue.getSeverityElement().setValue("warning");
break;
case INFO:
case SUCCESS:
continue;
}
issue.getDetailsElement().setValue(next.getAsString(Locale.getDefault()));
}
}
示例12: validate
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
public void validate(BPMNProcess process, ValidationResult validationResult)
throws ValidationException {
LOGGER.info("Validating {}", process.getBaseURI());
try {
// EXT.002 checks whether there are ID duplicates - as ID
// duplicates in a single file are already detected during XSD
// validation this is only relevant if other processes are imported
if(!process.getChildren().isEmpty()) {
ext002Checker.checkConstraint002(process, validationResult);
}
org.jdom2.Document documentToCheck = preProcessor.preProcess(process);
DOMOutputter domOutputter = new DOMOutputter();
Document w3cDoc = domOutputter
.output(documentToCheck);
DOMSource domSource = new DOMSource(w3cDoc);
for(ISchematronResource schematronFile : schemaToCheck) {
SchematronOutputType schematronOutputType = schematronFile
.applySchematronValidationToSVRL(domSource);
schematronOutputType.getActivePatternAndFiredRuleAndFailedAssert().stream()
.filter(obj -> obj instanceof FailedAssert)
.forEach(obj -> handleSchematronErrors(process, validationResult, (FailedAssert) obj));
}
} catch (Exception e) { // NOPMD
LOGGER.debug("exception during schematron validation. Cause: {}", e);
throw new ValidationException(
"Something went wrong during schematron validation!");
}
LOGGER.info("Validating process successfully done, file is valid: {}",
validationResult.isValid());
}
示例13: getSchematronValidity
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Nonnull
public EValidity getSchematronValidity (@Nonnull final SchematronOutputType aSO)
{
for (final Object aObj : aSO.getActivePatternAndFiredRuleAndFailedAssert ())
if (aObj instanceof FailedAssert || aObj instanceof SuccessfulReport)
return EValidity.INVALID;
return EValidity.VALID;
}
示例14: getSchematronValidity
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Nonnull
public EValidity getSchematronValidity (@Nonnull final SchematronOutputType aSO)
{
for (final Object aObj : aSO.getActivePatternAndFiredRuleAndFailedAssert ())
if (aObj instanceof FailedAssert)
return EValidity.INVALID;
return EValidity.VALID;
}
示例15: getSchematronValidity
import org.oclc.purl.dsdl.svrl.SchematronOutputType; //导入依赖的package包/类
@Nonnull
public EValidity getSchematronValidity (@Nonnull final Node aXMLNode,
@Nullable final String sBaseURI) throws Exception
{
ValueEnforcer.notNull (aXMLNode, "XMLNode");
// We don't have a short circuit here - apply the full validation
final SchematronOutputType aSO = applySchematronValidationToSVRL (aXMLNode, sBaseURI);
if (aSO == null)
return EValidity.INVALID;
// And now filter all elements that make the passed source invalid
return m_aXSLTValidator.getSchematronValidity (aSO);
}