Skip to content

Commit

Permalink
Added check for error roles in #66
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Aug 13, 2018
1 parent 41888dc commit 285ee12
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright (C) 2017-2018 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.schematron.ant;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class Issue66v2Test
{
private static final Logger LOGGER = LoggerFactory.getLogger (Issue66v2Test.class);

@Rule
public final BuildFileRule m_aBuildRule = new BuildFileRule ();

@Before
public void init ()
{
m_aBuildRule.configureProject ("src/test/resources/issues/66v2/build.xml");
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ());
}

@Test
public void testWithExternalDTD ()
{
try
{
// Do not redirect stdout etc.
m_aBuildRule.getProject ().executeTarget ("schematron");
}
catch (final BuildException ex)
{
LOGGER.error ("Ooops", ex);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
17 changes: 17 additions & 0 deletions ph-schematron-ant-task/src/test/resources/issues/66v2/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" />

<target name="schematron" description="Schematron rule tests">
<schematron svrlDirectory="tmp"
schematronProcessingEngine="pure"
schematronFile="rules.sch">
<fileset dir=".">
<include name="dog*.xml" />
</fileset>
<errorRole role="foo" />
<errorRole role="bar" />
</schematron>
</target>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<dog xml:lang="de">
<fleas/>
</dog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron" xml:lang="de">
<title>Example of a custom error role</title>
<pattern>
<rule context="dog">
<report test="not(bone)" role="bar"> A dog should have a bone.</report>
<report test="not(xyz)" role="info">Information only that xyz should be present.</report>
</rule>
</pattern>
</schema>

0 comments on commit 285ee12

Please sign in to comment.