Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //An XMLFrag is either a:
- //Plaintext -> which is just a normal string
- //Tagged -> A tag and a List-of XMLFrags
- //A Tag is a String (the tag name) and a List-of Attributes
- //An Attribute is a String (the name of the attribute) and another string representing the
- // "value" of the attribute (some XML jargon)
- //An XML-Document (what we are creating examples of and manipulating) is a List-of XMLFrags
- //List-of XMLFragment
- interface LoIXMLFrag {}
- //List-of Attribute
- interface ILoAttribute {}
- interface IXMLFrag {}
- //Empty list of Attributes
- class MtAttribute implements ILoAttribute {
- MtAttribute() {}
- }
- //Non-empty list of Attributes
- class ConsAttribute implements ILoAttribute {
- Attribute first;
- ILoAttribute rest;
- public ConsAttribute(Attribute first, ILoAttribute rest) {
- this.first = first;
- this.rest = rest;
- }
- }
- class MtIXMLFrag implements LoIXMLFrag{
- MtIXMLFrag(){}
- }
- class ConsIXMLFrag implements LoIXMLFrag{
- IXMLFrag first;
- LoIXMLFrag rest;
- public ConsIXMLFrag(IXMLFrag first, LoIXMLFrag rest) {
- this.first = first;
- this.rest = rest;
- }
- }
- class Plaintext implements IXMLFrag {
- String txt;
- Plaintext(String txtString) {
- this.txt = txtString;
- }
- }
- class Attribute implements IXMLFrag {
- String name;
- String value;
- public Attribute(String name, String value) {
- this.name = name;
- this.value = value;
- }
- }
- class Tag implements IXMLFrag {
- String name;
- ILoAttribute atts;
- public Tag(String name, ILoAttribute atts) {
- this.name = name;
- this.atts = atts;
- }
- }
- class Tagged implements IXMLFrag {
- Tag tag;
- LoIXMLFrag content;
- public Tagged(Tag tag, LoIXMLFrag content) {
- this.tag = tag;
- this.content = content;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement