Remove \t and whitespaces from xml
This commit is contained in:
@@ -3,11 +3,6 @@ package org.mustangproject.validator;
|
||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
@@ -21,9 +16,9 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
// ignored for the
|
||||
// time being
|
||||
|
||||
ValidationContext ctx = new ValidationContext(null);
|
||||
XMLValidator xv = new XMLValidator(ctx);
|
||||
XPathEngine xpath = new JAXPXPathEngine();
|
||||
final ValidationContext ctx = new ValidationContext(null);
|
||||
final XMLValidator xv = new XMLValidator(ctx);
|
||||
final XPathEngine xpath = new JAXPXPathEngine();
|
||||
File tempFile = getResourceAsFile("invalidV2.xml");
|
||||
Source source;
|
||||
String content;
|
||||
@@ -38,31 +33,31 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
* assertEquals(true, xv.getXMLResult().
|
||||
* contains("<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='ApplicableHeaderTradeSettlement']/*[local-name()='SpecifiedTradeSettlementHeaderMonetarySummation']\" criterion=\"(ram:LineTotalAmount)\">\n"
|
||||
* +
|
||||
* " Eine Rechnung (INVOICE) muss die Summe der Rechnungspositionen-Nettobeträge „Sum of Invoice line net amount“ (BT-106) enthalten.</error>\n"
|
||||
* "Eine Rechnung (INVOICE) muss die Summe der Rechnungspositionen-Nettobeträge „Sum of Invoice line net amount“ (BT-106) enthalten.</error>\n"
|
||||
* +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='ApplicableHeaderTradeSettlement']/*[local-name()='SpecifiedTradeSettlementHeaderMonetarySummation']\" criterion=\"(ram:TaxBasisTotalAmount = ram:LineTotalAmount - ram:AllowanceTotalAmount + ram:ChargeTotalAmount) or ((ram:TaxBasisTotalAmount = ram:LineTotalAmount - ram:AllowanceTotalAmount) and not (ram:ChargeTotalAmount)) or ((ram:TaxBasisTotalAmount = ram:LineTotalAmount + ram:ChargeTotalAmount) and not (ram:AllowanceTotalAmount)) or ((ram:TaxBasisTotalAmount = ram:LineTotalAmount) and not (ram:ChargeTotalAmount) and not (ram:AllowanceTotalAmount))\">\n"
|
||||
* +
|
||||
* " Der Inhalt des Elementes „Invoice total amount without VAT“ (BT-109) entspricht der Summe aller Inhalte der Elemente „Invoice line net amount“ (BT-131) abzüglich der Summe aller in der Rechnung enthaltenen Nachlässe der Dokumentenebene „Sum of allowances on document level“ (BT-107) zuzüglich der Summe aller in der Rechnung enthaltenen Abgaben der Dokumentenebene „Sum of charges on document level“ (BT-108).</error>\n"
|
||||
* "Der Inhalt des Elementes „Invoice total amount without VAT“ (BT-109) entspricht der Summe aller Inhalte der Elemente „Invoice line net amount“ (BT-131) abzüglich der Summe aller in der Rechnung enthaltenen Nachlässe der Dokumentenebene „Sum of allowances on document level“ (BT-107) zuzüglich der Summe aller in der Rechnung enthaltenen Abgaben der Dokumentenebene „Sum of charges on document level“ (BT-108).</error>\n"
|
||||
* +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='ApplicableHeaderTradeSettlement']/*[local-name()='SpecifiedTradeSettlementHeaderMonetarySummation']\" criterion=\"(ram:GrandTotalAmount = round(ram:TaxBasisTotalAmount*100 + ram:TaxTotalAmount[@currencyID=/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode]*100 +0) div 100) or ((ram:GrandTotalAmount = ram:TaxBasisTotalAmount) and not (ram:TaxTotalAmount[@currencyID=/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode]))\">\n"
|
||||
* +
|
||||
* " Der Inhalt des Elementes „Invoice total amount with VAT“ (BT-112) entspricht der Summe des Inhalts des Elementes „Invoice total amount without VAT“ (BT-109) und des Elementes „Invoice total VAT amount“ (BT-110).</error>\n"
|
||||
* "Der Inhalt des Elementes „Invoice total amount with VAT“ (BT-112) entspricht der Summe des Inhalts des Elementes „Invoice total amount without VAT“ (BT-109) und des Elementes „Invoice total VAT amount“ (BT-110).</error>\n"
|
||||
* +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='ApplicableHeaderTradeSettlement']/*[local-name()='SpecifiedTradeSettlementHeaderMonetarySummation']\" criterion=\"ram:LineTotalAmount = (round(sum(../../ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount) * 10 * 10)div 100)\">\n"
|
||||
* +
|
||||
* " Der Inhalt des Elementes „Sum of Invoice line net amount“ (BT-106) entspricht der Summe aller Inhalte der Elemente „Invoice line net amount“ (BT-131).</error>\n"
|
||||
* "Der Inhalt des Elementes „Sum of Invoice line net amount“ (BT-106) entspricht der Summe aller Inhalte der Elemente „Invoice line net amount“ (BT-131).</error>\n"
|
||||
* +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']\" criterion=\"(rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty/ram:Name!='')\">\n"
|
||||
* +
|
||||
* " Eine Rechnung (INVOICE) muss den Erwerbernamen „Buyer name“ (BT-44) enthalten.</error>\n"
|
||||
* "Eine Rechnung (INVOICE) muss den Erwerbernamen „Buyer name“ (BT-44) enthalten.</error>\n"
|
||||
* +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='ApplicableHeaderTradeAgreement']/*[local-name()='BuyerTradeParty']\" criterion=\"count(ram:Name)=1\">\n"
|
||||
* + " Das Element 'ram:Name' muss genau 1 mal auftreten.</error>\n" +
|
||||
* + "Das Element 'ram:Name' muss genau 1 mal auftreten.</error>\n" +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='ApplicableHeaderTradeSettlement']/*[local-name()='SpecifiedTradeSettlementHeaderMonetarySummation']\" criterion=\"count(ram:LineTotalAmount)=1\">\n"
|
||||
* + " Das Element 'ram:LineTotalAmount' muss genau 1 mal auftreten.</error>\n"
|
||||
* + "Das Element 'ram:LineTotalAmount' muss genau 1 mal auftreten.</error>\n"
|
||||
* +
|
||||
* "<error location=\"/*[local-name()='CrossIndustryInvoice']/*[local-name()='SupplyChainTradeTransaction']/*[local-name()='IncludedSupplyChainTradeLineItem'][2]/*[local-name()='SpecifiedLineTradeDelivery']/*[local-name()='BilledQuantity']\" criterion=\"document('zugferd2p0_extended_codedb.xml')//cl[@id=7]/enumeration[@value=$codeValue7]\">\n"
|
||||
* + " Wert von '@unitCode' ist unzulässig.</error>\n" +
|
||||
* + "Wert von '@unitCode' ist unzulässig.</error>\n" +
|
||||
* "</messages><summary status='invalid'/>"));
|
||||
*
|
||||
*/
|
||||
@@ -72,7 +67,7 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
xv.setFilename(tempFile.getAbsolutePath());
|
||||
|
||||
xv.validate();
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
} catch (final IrrecoverableValidationError e) {
|
||||
noException = false; //expecting a fatal error, i.e. an exception
|
||||
}
|
||||
assertFalse(noException);
|
||||
@@ -87,10 +82,10 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
xv.setFilename(tempFile.getAbsolutePath());
|
||||
|
||||
xv.validate();
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
} catch (final IrrecoverableValidationError e) {
|
||||
noException = false;
|
||||
}
|
||||
String res = xv.getXMLResult();
|
||||
final String res = xv.getXMLResult();
|
||||
/*OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(new File("return.xml"));
|
||||
@@ -166,7 +161,7 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
source = Input.fromString("<validation>" + xv.getXMLResult() + "</validation>").build();
|
||||
content = xpath.evaluate("/validation/summary/@status", source);
|
||||
assertEquals("invalid", content);
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
} catch (final IrrecoverableValidationError e) {
|
||||
// ignore, will be in XML output anyway
|
||||
noException = false;
|
||||
}
|
||||
@@ -177,7 +172,7 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
xv.setFilename(tempFile.getAbsolutePath());
|
||||
xv.validate();
|
||||
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
} catch (final IrrecoverableValidationError e) {
|
||||
// do expect this!
|
||||
noException = false;
|
||||
}
|
||||
@@ -187,8 +182,8 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
}
|
||||
|
||||
public void testZF1XMLValidation() {
|
||||
ValidationContext ctx = new ValidationContext(null);
|
||||
XMLValidator xv = new XMLValidator(ctx);
|
||||
final ValidationContext ctx = new ValidationContext(null);
|
||||
final XMLValidator xv = new XMLValidator(ctx);
|
||||
File tempFile = getResourceAsFile("validV1.xml");
|
||||
try {
|
||||
xv.setFilename(tempFile.getAbsolutePath());
|
||||
@@ -205,16 +200,16 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
xv.validate();
|
||||
assertEquals(true, xv.getXMLResult().contains("<error type=\"26\""));
|
||||
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
} catch (final IrrecoverableValidationError e) {
|
||||
// ignore, will be in XML output anyway
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testXRValidation() {
|
||||
ValidationContext ctx = new ValidationContext(null);
|
||||
XMLValidator xv = new XMLValidator(ctx);
|
||||
XPathEngine xpath = new JAXPXPathEngine();
|
||||
final ValidationContext ctx = new ValidationContext(null);
|
||||
final XMLValidator xv = new XMLValidator(ctx);
|
||||
final XPathEngine xpath = new JAXPXPathEngine();
|
||||
|
||||
File tempFile = getResourceAsFile("validXRv2.xml");
|
||||
try {
|
||||
@@ -234,7 +229,7 @@ public class XMLValidatorTest extends ResourceCase {
|
||||
assertEquals("invalid", content);
|
||||
|
||||
|
||||
} catch (IrrecoverableValidationError e) {
|
||||
} catch (final IrrecoverableValidationError e) {
|
||||
// ignore, will be in XML output anyway
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user