Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
karlkauc committed Jan 8, 2024
1 parent 9d019d3 commit 8eb2313
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void setCurrentXmlFile(File currentXmlFile) {

try {
var schemaLocation = getSchemaNameFromCurrentXMLFile();
if (schemaLocation.isPresent() && schemaLocation.get().length() > 0) {
if (schemaLocation.isPresent() && !schemaLocation.get().isEmpty()) {
remoteXsdLocation = schemaLocation.get();
}
} catch (Exception ignore) {
Expand Down Expand Up @@ -196,7 +196,6 @@ public void setCurrentXsltFile(File currentXsltFile) {
final var builder = builderFactory.newDocumentBuilder();
final var xmlDocument = builder.parse(fileIS);


final String expression = "/stylesheet/output/@method";
final XPath xPath = XPathFactory.newInstance().newXPath();
final var nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
Expand Down Expand Up @@ -736,7 +735,6 @@ static boolean isContainBOM(Path path) {

byte[] bom = new byte[3];
try (InputStream is = new FileInputStream(path.toFile())) {

// read 3 bytes of a file.
is.read(bom);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ public void copyResources(File outputDirectory) {
}

public void generateRootPage(File outputDirectory) {
final var rootElementName = elements.get(0).getName();
final var rootElementName = elements.getFirst().getName();

var context = new Context();
context.setVariable("date", LocalDate.now());
context.setVariable("filename", this.getXsdFilePath());
context.setVariable("rootElementName", rootElementName);
context.setVariable("rootElement", getXmlSchema().get(0));
context.setVariable("xsdElements", elements.get(0));
context.setVariable("rootElement", getXmlSchema().getFirst());
context.setVariable("xsdElements", elements.getFirst());
context.setVariable("xsdComplexTypes", getXsdComplexTypes());
context.setVariable("xsdSimpleTypes", getXsdSimpleTypes());
context.setVariable("rootElementLink", "details/" + getExtendedXsdElements().get("/" + rootElementName).getPageName());
Expand Down Expand Up @@ -226,11 +226,10 @@ public void generateComplexTypePages(File outputDirectory) {

public String getChildInfo(String xpath) {
try {
StringBuilder sb = new StringBuilder();
for (var doc : getExtendedXsdElements().get(xpath).getXsdDocumentation()) {
sb.append(doc.getContent());
}
return sb.toString();
return getExtendedXsdElements().get(xpath).getXsdDocumentation()
.stream()
.map(XsdAnnotationChildren::getContent)
.collect(Collectors.joining());
} catch (Exception e) {
logger.debug("ERROR: {}", e.getMessage());
}
Expand All @@ -250,7 +249,7 @@ public void generateDetailPages(File outputDirectory) {
context.setVariable("xpath", getBreadCrumbs(currentElement));
context.setVariable("code", currentElement.getSourceCode());
context.setVariable("element", currentElement);
context.setVariable("namespace", getXmlSchema().get(0).getTargetNamespace());
context.setVariable("namespace", getXmlSchema().getFirst().getTargetNamespace());
context.setVariable("this", this);

if (currentElement.getXsdElement() != null && currentElement.getXsdElement().getType() != null) {
Expand Down Expand Up @@ -502,8 +501,8 @@ public void processXsd(Boolean useMarkdownRenderer) {
elements = parser.getResultXsdElements().collect(Collectors.toList());
xmlSchema = parser.getResultXsdSchemas().toList();

xsdComplexTypes = xmlSchema.get(0).getChildrenComplexTypes().collect(Collectors.toList());
xsdSimpleTypes = xmlSchema.get(0).getChildrenSimpleTypes().collect(Collectors.toList());
xsdComplexTypes = xmlSchema.getFirst().getChildrenComplexTypes().collect(Collectors.toList());
xsdSimpleTypes = xmlSchema.getFirst().getChildrenSimpleTypes().collect(Collectors.toList());

extendedXsdElements = new LinkedHashMap<>();
counter = 0;
Expand Down

0 comments on commit 8eb2313

Please sign in to comment.