[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-libeufin] 08/25: Drafting XSD import from disk, and
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-libeufin] 08/25: Drafting XSD import from disk, and XML validation. |
Date: |
Fri, 20 Sep 2019 19:32:46 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
commit d28fa7e89b7ac1e3c2dc7652ced1da1c44cf003f
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sun Sep 15 18:24:49 2019 +0200
Drafting XSD import from disk, and XML validation.
---
src/main/java/XMLManagement.java | 11 ------
src/main/java/tech/libeufin/XMLManagement.java | 52 ++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/src/main/java/XMLManagement.java b/src/main/java/XMLManagement.java
deleted file mode 100644
index c80cb26..0000000
--- a/src/main/java/XMLManagement.java
+++ /dev/null
@@ -1,11 +0,0 @@
-
-/**
- * This class takes care of importing XSDs and validate
- * XMLs against those.
- */
-
-public class XMLManagement {
- public void printtheline(){
- System.out.println("Hello Java World.");
- }
-};
\ No newline at end of file
diff --git a/src/main/java/tech/libeufin/XMLManagement.java
b/src/main/java/tech/libeufin/XMLManagement.java
new file mode 100644
index 0000000..0c21cc9
--- /dev/null
+++ b/src/main/java/tech/libeufin/XMLManagement.java
@@ -0,0 +1,52 @@
+package tech.libeufin;
+
+import org.xml.sax.SAXException;
+import java.io.IOException;
+import javax.xml.XMLConstants;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.Source;
+import javax.xml.validation.*; // has SchemaFactory
+import java.io.File;
+
+/**
+ * This class takes care of importing XSDs and validate
+ * XMLs against those.
+ */
+
+public class XMLManagement {
+
+ /**
+ * Bundle of all the XSDs loaded in memory.
+ */
+ Schema bundle;
+ Validator validator;
+
+ /**
+ * Load all the XSDs from disk.
+ */
+ public XMLManagement(){
+
+ Source ebics_hev_file = new StreamSource(new
File("resources/ebics_hev.xsd"));
+ Source xsds[] = {ebics_hev_file};
+ SchemaFactory sf = new
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
+
+ try{
+ this.bundle = sf.newSchema(xsds);
+ this.validator = this.bundle.newValidator();
+ } catch (IOException e){
+ System.out.println("Could not import all XSDs from disk" + "(" + e
+ ")");
+ }
+ }
+
+ public boolean validate(Source xmlDoc){
+ try{
+ this.validator.validate(xmlDoc);
+ } catch (SAXException e) {
+ return false;
+ } catch (IOException e) {
+ System.out.println("Could not pass XML to validator.");
+ return false;
+ }
+
+ }
+};
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-libeufin] branch master created (now 62598ec), gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 04/25: Instructions for running under MS Windows., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 08/25: Drafting XSD import from disk, and XML validation.,
gnunet <=
- [GNUnet-SVN] [taler-libeufin] 02/25: instructions for running the sandbox, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 09/25: load xsd from resources, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 07/25: Test stub., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 06/25: readme, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 05/25: Copyright header., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 01/25: Import initial project structure., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 10/25: fix resource loading, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 03/25: AGPL license, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 12/25: Local test of XML validation., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 11/25: import sample hev, gnunet, 2019/09/20