From 2e3486e39a1e8244c9d78538e7619eaeefec87e2 Mon Sep 17 00:00:00 2001 From: nikolaibeliaev Date: Fri, 15 Mar 2019 11:08:14 +0700 Subject: [PATCH] initial commit --- .gitignore | 7 +++ example.xml | 65 ++++++++++++++++++++++++++++ src/dev/fr13/XsdSchema.java | 85 +++++++++++++++++++++++++++++++++++++ примерсхемыкакматрешка.xsd | 24 +++++++++++ 4 files changed, 181 insertions(+) create mode 100644 .gitignore create mode 100644 example.xml create mode 100644 src/dev/fr13/XsdSchema.java create mode 100644 примерсхемыкакматрешка.xsd diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fad1678 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +*.jar +.DS_Store \ No newline at end of file diff --git a/example.xml b/example.xml new file mode 100644 index 0000000..b5387d0 --- /dev/null +++ b/example.xml @@ -0,0 +1,65 @@ + + + + 01GTKT + 01GTKT0/001 + VND + 1 + true + TM + TM + true + 123456789 + 1 + + + Lương Thị Huyền + + 3901212654 + HN VN + 09880830406 + + 123456789 + 1 + + + Supplier perfom test 1 + 0100109106-501 + test + 0123456789 + PerformanceTest1@viettel.com.vn + vtbank + 23423424 + + + TM + + + + 1 + ENGLISH_COURSE + Khóa học tiếng anh + khóa học + 3500000 + 10 + 35000000 + 10 + 3500000 + 0 + 0 + + + 35000000 + 35000000 + 3500000 + 38500000 + Ba mươi tám triệu năm trăm nghìn đồng chẵn + 0 + 10 + + + 10 + 35000000 + 3500000 + + diff --git a/src/dev/fr13/XsdSchema.java b/src/dev/fr13/XsdSchema.java new file mode 100644 index 0000000..1cf562f --- /dev/null +++ b/src/dev/fr13/XsdSchema.java @@ -0,0 +1,85 @@ +package dev.fr13; + +import org.apache.xmlbeans.impl.inst2xsd.Inst2XsdOptions; + +import java.io.File; +import java.io.FileNotFoundException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class XsdSchema { + + private File sourceFile; + private boolean printHelp = false; + + public static void main(String[] args) throws FileNotFoundException { + // write your code here + XsdSchema xsdSchema = new XsdSchema(args); + if (xsdSchema.getPrintHelp()) { + + } else { + xsdSchema.checkSourceFile(); + } + + Inst2XsdOptions inst2XsdOptions = new Inst2XsdOptions(); + //XmlObject.Factory.parse("src\\dev\\fr13\example.xml") + } + + XsdSchema(String[] args) { + + int argsCount = args.length; + String pathToFile = ""; + + if (argsCount == 0) { + return; + } + + for (int i=0; i < args.length; i++) { + + switch (args[i]) { + case "-i": + pathToFile = args.length > 1 ? args[i + 1]:""; + break; + case "--input": + pathToFile = args.length > 1 ? args[i + 1]:""; + break; + case "-h": + setPrintHelp(true); + break; + case "--help": + setPrintHelp(true); + break; + } + + if (printHelp) { + pathToFile = ""; + break; + } + } + + if (pathToFile.isEmpty()) { + return; + } + + sourceFile = new File(pathToFile); + + } + + private boolean getPrintHelp() { + return printHelp; + } + + private void setPrintHelp(boolean printHelp) { + this.printHelp = printHelp; + } + + private void checkSourceFile() throws FileNotFoundException { + + Path path = Paths.get(sourceFile.toURI()); + if (Files.notExists(path)) { + throw new FileNotFoundException("no such file " + sourceFile.getPath()); + } + + } +} diff --git a/примерсхемыкакматрешка.xsd b/примерсхемыкакматрешка.xsd new file mode 100644 index 0000000..02e1e33 --- /dev/null +++ b/примерсхемыкакматрешка.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file