1
0
mirror of https://github.com/fr13Dev/generatingXSD synced 2024-12-22 11:03:13 +00:00

initial commit

This commit is contained in:
nikolaibeliaev 2019-03-15 11:08:14 +07:00
commit 2e3486e39a
4 changed files with 181 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
*.jar
.DS_Store

65
example.xml Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" ?>
<commonInvoiceInput>
<generalInvoiceInfo>
<invoiceType>01GTKT</invoiceType>
<templateCode>01GTKT0/001</templateCode>
<currencyCode>VND</currencyCode>
<adjustmentType>1</adjustmentType>
<paymentStatus>true</paymentStatus>
<paymentType>TM</paymentType>
<paymentTypeName>TM</paymentTypeName>
<cusGetInvoiceRight>true</cusGetInvoiceRight>
<buyerIdNo>123456789</buyerIdNo>
<buyerIdType>1</buyerIdType>
</generalInvoiceInfo>
<buyerInfo>
<buyerName>Lương Thị Huyền</buyerName>
<buyerLegalName></buyerLegalName>
<buyerTaxCode>3901212654</buyerTaxCode>
<buyerAddressLine>HN VN</buyerAddressLine>
<buyerPhoneNumber>09880830406</buyerPhoneNumber>
<buyerEmail></buyerEmail>
<buyerIdNo>123456789</buyerIdNo>
<buyerIdType>1</buyerIdType>
</buyerInfo>
<sellerInfo>
<sellerLegalName>Supplier perfom test 1</sellerLegalName>
<sellerTaxCode>0100109106-501</sellerTaxCode>
<sellerAddressLine>test</sellerAddressLine>
<sellerPhoneNumber>0123456789</sellerPhoneNumber>
<sellerEmail>PerformanceTest1@viettel.com.vn</sellerEmail>
<sellerBankName>vtbank</sellerBankName>
<sellerBankAccount>23423424</sellerBankAccount>
</sellerInfo>
<payments>
<paymentMethodName>TM</paymentMethodName>
</payments>
<deliveryInfo />
<itemInfo>
<lineNumber>1</lineNumber>
<itemCode>ENGLISH_COURSE</itemCode>
<itemName>Khóa học tiếng anh</itemName>
<unitName>khóa học</unitName>
<unitPrice>3500000</unitPrice>
<quantity>10</quantity>
<itemTotalAmountWithoutTax>35000000</itemTotalAmountWithoutTax>
<taxPercentage>10</taxPercentage>
<taxAmount>3500000</taxAmount>
<discount>0</discount>
<itemDiscount>0</itemDiscount>
</itemInfo>
<summarizeInfo>
<sumOfTotalLineAmountWithoutTax>35000000</sumOfTotalLineAmountWithoutTax>
<totalAmountWithoutTax>35000000</totalAmountWithoutTax>
<totalTaxAmount>3500000</totalTaxAmount>
<totalAmountWithTax>38500000</totalAmountWithTax>
<totalAmountWithTaxInWords>Ba mươi tám triệu năm trăm nghìn đồng chẵn</totalAmountWithTaxInWords>
<discountAmount>0</discountAmount>
<taxPercentage>10</taxPercentage>
</summarizeInfo>
<taxBreakdowns>
<taxPercentage>10</taxPercentage>
<taxableAmount>35000000</taxableAmount>
<taxAmount>3500000</taxAmount>
</taxBreakdowns>
</commonInvoiceInput>

View File

@ -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());
}
}
}

View File

@ -0,0 +1,24 @@
<xs:schema xmlns:tns="http://test" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="CustomerId" type="xs:int"/>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:element name="City" type="xs:string"/>
<xs:element name="Zip" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Info">
<xs:sequence>
<xs:element ref="tns:Customer"/>
</xs:sequence>
</xs:complexType>
</xs:schema>