Package gov.niem.tools.api.validation
Class ValidationUtils
java.lang.Object
gov.niem.tools.api.validation.ValidationUtils
- Direct Known Subclasses:
XmlValidationUtils
Utility functions supporting validation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic File
convertClassPathResourceToFile
(Path tempPath, String classPath, String filename) Saves the file in the resources directory with the given class path to the given temporary path and returns the file.static void
copyClasspathFiles
(Path tempPath, String resourcesPathString) Saves all files (may be nested) at the given path in the resources directory to the given temporary path.static Path
static Source[]
getClasspathXsdSources
(String resourcesPathString) Converts XSD files at the given path in the resources directory to source objects that can be used for validation.static Document
getDocument
(File file) Converts an XML text file to a DOM document with nodes and other DOM objects.static XPath
getXpath()
Gets an object that can be used to evaluate xPath expressions that binds namespace prefixes `xs` and `ct` to the URIs for XML Schema and the NIEM conformance targets attribute.static Node
getXpathResult
(Document document, XPath xpath, String expression) Gets the node at the given xPath expression.static NodeList
getXpathResults
(Document document, XPath xpath, String expression) Gets a NodeList for all nodes matching the given xPath expression.static String
getXpathResultText
(Document document, XPath xpath, String expression) Gets the text content of the node at the given xPath expression.static String
getXsdRootAttributeValue
(Document document, XPath xpath, String attributeName) Gets the values of the given schema-level attribute.
-
Field Details
-
TEMP_DIR_BASE
- See Also:
-
TEMP_DIR_PREFIX
- See Also:
-
-
Constructor Details
-
ValidationUtils
public ValidationUtils()
-
-
Method Details
-
createTempFolder
- Throws:
IOException
-
convertClassPathResourceToFile
public static File convertClassPathResourceToFile(Path tempPath, String classPath, String filename) throws IOException Saves the file in the resources directory with the given class path to the given temporary path and returns the file.- Throws:
IOException
-
copyClasspathFiles
Saves all files (may be nested) at the given path in the resources directory to the given temporary path.- Throws:
IOException
-
getClasspathXsdSources
Converts XSD files at the given path in the resources directory to source objects that can be used for validation.- Throws:
IOException
-
getDocument
public static Document getDocument(File file) throws ParserConfigurationException, SAXException, IOException Converts an XML text file to a DOM document with nodes and other DOM objects. -
getXpath
Gets an object that can be used to evaluate xPath expressions that binds namespace prefixes `xs` and `ct` to the URIs for XML Schema and the NIEM conformance targets attribute.- Throws:
ParserConfigurationException
SAXException
IOException
- Todo:
- Fix conformance target support for 6.0
-
getXsdRootAttributeValue
public static String getXsdRootAttributeValue(Document document, XPath xpath, String attributeName) throws XPathExpressionException Gets the values of the given schema-level attribute.- Throws:
XPathExpressionException
-
getXpathResults
public static NodeList getXpathResults(Document document, XPath xpath, String expression) throws XPathExpressionException Gets a NodeList for all nodes matching the given xPath expression.- Throws:
XPathExpressionException
-
getXpathResult
public static Node getXpathResult(Document document, XPath xpath, String expression) throws XPathExpressionException Gets the node at the given xPath expression.- Throws:
XPathExpressionException
-
getXpathResultText
public static String getXpathResultText(Document document, XPath xpath, String expression) throws XPathExpressionException Gets the text content of the node at the given xPath expression.- Throws:
XPathExpressionException
-