BAEL-5755: indention update

This commit is contained in:
Vladyslav Chernov 2023-11-22 16:06:21 -08:00
parent ee97389e28
commit 7deec4a5e0
2 changed files with 11 additions and 11 deletions

View File

@ -40,7 +40,7 @@ public class Xml2CsvExample {
protected static void convertXml2CsvXslt(String xslPath, String xmlPath, String csvPath) throws IOException, TransformerException { protected static void convertXml2CsvXslt(String xslPath, String xmlPath, String csvPath) throws IOException, TransformerException {
StreamSource styleSource = new StreamSource(new File(xslPath)); StreamSource styleSource = new StreamSource(new File(xslPath));
Transformer transformer = TransformerFactory.newInstance() Transformer transformer = TransformerFactory.newInstance()
.newTransformer(styleSource); .newTransformer(styleSource);
Source source = new StreamSource(new File(xmlPath)); Source source = new StreamSource(new File(xmlPath));
Result outputTarget = new StreamResult(new File(csvPath)); Result outputTarget = new StreamResult(new File(csvPath));
transformer.transform(source, outputTarget); transformer.transform(source, outputTarget);
@ -68,26 +68,26 @@ public class Xml2CsvExample {
if ("Bookstore".equals(currentElement)) { if ("Bookstore".equals(currentElement)) {
bookstoreInfo.setLength(0); bookstoreInfo.setLength(0);
bookstoreInfo.append(reader.getAttributeValue(null, "id")) bookstoreInfo.append(reader.getAttributeValue(null, "id"))
.append(","); .append(",");
} }
if ("Book".equals(currentElement)) { if ("Book".equals(currentElement)) {
csvRow.append(bookstoreInfo) csvRow.append(bookstoreInfo)
.append(reader.getAttributeValue(null, "id")) .append(reader.getAttributeValue(null, "id"))
.append(",") .append(",")
.append(reader.getAttributeValue(null, "category")) .append(reader.getAttributeValue(null, "category"))
.append(","); .append(",");
} }
if ("Author".equals(currentElement)) { if ("Author".equals(currentElement)) {
csvRow.append(reader.getAttributeValue(null, "id")) csvRow.append(reader.getAttributeValue(null, "id"))
.append(","); .append(",");
} }
break; break;
case XMLStreamConstants.CHARACTERS: case XMLStreamConstants.CHARACTERS:
if (!reader.isWhiteSpace()) { if (!reader.isWhiteSpace()) {
csvRow.append(reader.getText() csvRow.append(reader.getText()
.trim()) .trim())
.append(","); .append(",");
} }
break; break;

View File

@ -91,7 +91,7 @@ public class Xml2CsvExampleUnitTest {
Xml2CsvExample.convertXml2CsvXslt(STYLE_XSL, DATA_XML, TEMP_OUTPUT_CSV); Xml2CsvExample.convertXml2CsvXslt(STYLE_XSL, DATA_XML, TEMP_OUTPUT_CSV);
File csvFile = new File(TEMP_OUTPUT_CSV); File csvFile = new File(TEMP_OUTPUT_CSV);
try(BufferedReader reader = new BufferedReader(new FileReader(csvFile))) { try (BufferedReader reader = new BufferedReader(new FileReader(csvFile))) {
String line; String line;
boolean isFirstLine = true; boolean isFirstLine = true;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
@ -113,7 +113,7 @@ public class Xml2CsvExampleUnitTest {
Xml2CsvExample.convertXml2CsvStax(DATA_XML, TEMP_OUTPUT_CSV); Xml2CsvExample.convertXml2CsvStax(DATA_XML, TEMP_OUTPUT_CSV);
File csvFile = new File(TEMP_OUTPUT_CSV); File csvFile = new File(TEMP_OUTPUT_CSV);
try(BufferedReader reader = new BufferedReader(new FileReader(csvFile))) { try (BufferedReader reader = new BufferedReader(new FileReader(csvFile))) {
String line; String line;
boolean isFirstLine = true; boolean isFirstLine = true;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {