diff --git a/src/ch/zhaw/ads/ADS1_4_test.java b/src/ch/zhaw/ads/ADS1_4_test.java index 6ed32c0..fcb48d2 100644 --- a/src/ch/zhaw/ads/ADS1_4_test.java +++ b/src/ch/zhaw/ads/ADS1_4_test.java @@ -1,4 +1,4 @@ -/* + package ch.zhaw.ads; import org.junit.jupiter.api.BeforeEach; @@ -34,4 +34,3 @@ public class ADS1_4_test { } } -*/ \ No newline at end of file diff --git a/src/ch/zhaw/ads/WellformedXmlServer.java b/src/ch/zhaw/ads/WellformedXmlServer.java index d6425a8..cbe1ac5 100644 --- a/src/ch/zhaw/ads/WellformedXmlServer.java +++ b/src/ch/zhaw/ads/WellformedXmlServer.java @@ -8,6 +8,43 @@ public class WellformedXmlServer implements CommandExecutor { } public boolean checkWellformed(String arg) { + Stack stack = new ListStack(); + char[] chars = arg.toCharArray(); + for(int i = 0; i < chars.length; i++){ + if(chars[i] == '<') { + boolean closing = false; + i++; + if(chars[i] == '/'){ + closing = true; + i++; + } + String tag = ""; + while(chars[i] != '>' && chars[i] != ' '){ + tag = tag + chars[i]; + i++; + } + if(tag.charAt(tag.length() - 1) == '/') { + } + else if (closing){ + if(!tag.equals(stack.pop())){ + return false; + } + } else { + stack.push(tag); + } + } + } + if(stack.isEmpty()){ + return true; + } else { + return false; + } } + + private String getNextToken(){ + return null; + } + + } \ No newline at end of file