Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. //An XMLFrag is either a:
  2. //Plaintext -> which is just a normal string
  3. //Tagged -> A tag and a List-of XMLFrags
  4.  
  5.  
  6. //A Tag is a String (the tag name) and a List-of Attributes
  7. //An Attribute is a String (the name of the attribute) and another string representing the
  8. // "value" of the attribute (some XML jargon)
  9. //An XML-Document (what we are creating examples of and manipulating) is a List-of XMLFrags
  10.  
  11.  
  12.  
  13. //List-of XMLFragment
  14. interface LoIXMLFrag {}
  15.  
  16. //List-of Attribute
  17. interface ILoAttribute {}
  18.  
  19. interface IXMLFrag {}
  20.  
  21. //Empty list of Attributes
  22. class MtAttribute implements ILoAttribute {
  23. MtAttribute() {}
  24. }
  25.  
  26. //Non-empty list of Attributes
  27. class ConsAttribute implements ILoAttribute {
  28. Attribute first;
  29. ILoAttribute rest;
  30.  
  31. public ConsAttribute(Attribute first, ILoAttribute rest) {
  32. this.first = first;
  33. this.rest = rest;
  34. }
  35. }
  36.  
  37. class MtIXMLFrag implements LoIXMLFrag{
  38. MtIXMLFrag(){}
  39. }
  40.  
  41. class ConsIXMLFrag implements LoIXMLFrag{
  42. IXMLFrag first;
  43. LoIXMLFrag rest;
  44.  
  45. public ConsIXMLFrag(IXMLFrag first, LoIXMLFrag rest) {
  46. this.first = first;
  47. this.rest = rest;
  48. }
  49. }
  50.  
  51. class Plaintext implements IXMLFrag {
  52. String txt;
  53.  
  54. Plaintext(String txtString) {
  55. this.txt = txtString;
  56. }
  57. }
  58.  
  59. class Attribute implements IXMLFrag {
  60. String name;
  61. String value;
  62.  
  63. public Attribute(String name, String value) {
  64. this.name = name;
  65. this.value = value;
  66. }
  67. }
  68.  
  69. class Tag implements IXMLFrag {
  70. String name;
  71. ILoAttribute atts;
  72.  
  73. public Tag(String name, ILoAttribute atts) {
  74. this.name = name;
  75. this.atts = atts;
  76. }
  77.  
  78. }
  79.  
  80. class Tagged implements IXMLFrag {
  81. Tag tag;
  82. LoIXMLFrag content;
  83.  
  84. public Tagged(Tag tag, LoIXMLFrag content) {
  85. this.tag = tag;
  86. this.content = content;
  87. }
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement