General XML Output for Part 2 (and Part 3)

Your output will be a series of elements in response to commands, each of which is a reaction to an issued command. Note that we will try to reuse as many of these as possible all semester, and will add new formats only when absolutely necessary. Note that this section will be as stable as we can make it, with modifications only as necessary.

One change we will be making is the addition of an id attribute to each <command> tag. This is just an integer that identifies the command; this should make it much easier to identify which input command is causing your output to differ from the correct output. You will simply copy the value of the id attribute in the input to an id attribute in the <command> tag of the corresponding output. The numbers below are just examples.

General <success> Output
This is an example of the form (in the exact output order) of a general <success> tag. All tags will be present even if there are no parameters or outputs.
    <success>
      <command name=''name1'' id=''1''/>
      <parameters>
          <param1 value=''value1''/>
          <param2 value=''value2''/>
      </parameters>
      <output/>
  </success>

General <error> Output

This is the form (in the exact output order) of a general <error> tag. The <parameters> tag will always be present even if there are no parameters to the command. In each command there may be several errors; in this case you will only output the error of highest priority. For more information see XML Input specification for each command.

<error type=''error1''>
    <command name=''name1'' id=''2''/>
    <parameters>
        <param1 value=''value1''/>
        <param2 value=''value2''/>
    </parameters>
</error>

General <fatalError> Output
This is the form of a General <fatalError> tag. This is used when there is a problem with the entire document

<fatalError/>

General <undefinedError> Output
This is the form of a general <undefinedError> tag. This is a default error that will be used if there is an error that is not specified in the spec and is discovered post freezing.

    <undefinedError />

General sorting of <city> and <road> tags.

Ordering of <city> tags that are contained within the <output> tag is in descending asciibetical order of the city's name according to the java.lang.String.comapreTo() method unless the method for sorting is specified within the command's specification.

Ordering of <road> tags that are contained within the <output> tag is in descending asciibetical order of the start city's name. If two roads have the same start city, the end city's names would appear in descending asciibetical order. The java.lang.String.compareTo() method is used unless the method of sorting is specified within the command's specification.

printPMQuadtree
Prints the PM quadtree. Since PM quadtrees are deterministic once the order of quadrants has been fixed, your XML should match exactly the primary input/output.

Parameter:
(none)
Possible <output>:
A <quadtree> tag will be contained within output. This tag will have one attribute order which will be the PM order of the tree you are printing (this is given in the commands tag). and will contain several <gray> <white> and <black> nodes.
The first node in the quadtree will be the root node, this node can be gray or black, then the rest of the PM Quadtree follows. Remember, the exact structure of the quadtree will be represented by the XML output.

<gray>
Nodes will contain 4 children nodes with ordering decided by the order of the nodes within the actual gray node in your PM Quad Tree.<gray> nodes will have the attributes x and y, these are integers that identify the location of the gray node. They will appear as such
<gray x=''72'' y=''40''>
    ...
</gray>

<black>
Nodes in a PMQuadtree can contain at most one <city> and possibly several <road> tags, depending on the type of tree (PM1,PM3).
The format of <city> and <road> tags will be as such:
<city name=''city1'' x=''coordx'' y=''coordy'' color=''color1'' radius=''radius1''/> <isolatedCity name=''city1'' x=''coordx'' y=''coordy'' color=''color1'' radius=''radius1''/> <road start=''city_a'' end=''city_b''/>
The ordering of the city and road tags within the black node will be as such, first the <city> or <isolatedCity> tag will be printed (if it exists) then the <road> tags will be printed in the ordering specified in the upcoming section. Since the roads are undirected, within the road tag, the end city is the one whose name is first in descending asciibetical order.
Black nodes have the attribute cardinality which is the number of cities and roads contained within the black node. Black nodes will appear as such:
    <black cardinality=''card''>
      ...
  </black>

<white>
Nodes represent an empty node in your PM Quad Tree and will appear as such;
<white/>
Possible <error> types:
mapIsEmpty
<success> Example:
<success>
    <command name=''printPMQuadtree'' id=''1''/>
    <parameters/>
    <output>
        <quadtree order=''3''>
            <gray x=''128'' y=''128''>
                <black cardinality=''2''>
                    <city color=''red'' name=''Berlin'' radius=''50'' x=''128'' y=''128'' />
                    <road end=''Geneva'' start=''Berlin'' />
                </black>
                <black cardinality=''2''>
                    <city color=''red'' name=''Berlin'' radius=''50'' x=''128'' y=''128'' />
                    <road end=''Geneva'' start=''Berlin'' />
                </black>
                <gray x=''64'' y=''64''>
                    <white />
                    <gray x=''96'' y=''96''>
                        <white />
                        <black cardinality=''2''>
                            <city color=''red'' name=''Berlin'' radius=''50'' x=''128'' y=''128'' />
                            <road end=''Geneva'' start=''Berlin'' />
                        </black>
                        <black cardinality=''3''>
                            <city color=''orange'' name=''Geneva'' radius=''80'' x=''90'' y=''70'' />
                            <road end=''Madrid'' start=''Geneva'' />
                            <road end=''Geneva'' start=''Berlin'' />
                        </black>
                        <black cardinality=''2''>
                            <isolatedCity color=''black'' name=''Paris'' radius=''10'' x=''50'' y=''30''/>
                            <road end=''Geneva'' start=''Berlin'' />
                        </black>
                    </gray>
                    <black cardinality=''2''>
                        <city color=''yellow'' name=''Madrid'' radius=''60'' x=''45'' y=''50'' />
                        <road end=''Madrid'' start=''Geneva'' />
                    </black>
                    <black cardinality=''1''>
                        <road end=''Madrid'' start=''Geneva'' />
                    </black>
                </gray>
                <black cardinality=''2''>
                    <city color=''red'' name=''Berlin'' radius=''50'' x=''128'' y=''128'' />
                    <road end=''Geneva'' start=''Berlin'' />
                </black>
            </gray>
        </quadtree>
    </output>
</success>

printTreap

Prints the Treap. Treap are not deterministic so your output may vary from the sample files that we give you

Parameter:

(none)
Possible <output>:
A <treap> node will be contained within the output tag and is the root of the Treap xml tree. This tag has one required attribute: cardinality, whose value should be the size (number of keys) held by the treap.

<node>
Represents a node in the Treap. This element has three attributes: key, value, and priority. It will have two children, each of which can be a <node> or a <emptyChild>.

<emptyChild>
Represents an empty child in the Treap.

Possible <error> types:

emptyTree
<success> Example:
   <success>
    <command id=''4'' name=''printTreap''/>
    <parameters/>
    <output>
      <treap cardinality=''2''>
        <node key=''Baltimore'' priority=''844902938'' value=''(140,37)''>
          <node key=''Chicago'' priority=''-1294899492'' value=''(133,34)''>
            <emptyChild/>
            <emptyChild/>
          </node>
          <emptyChild/>
        </node>
      </treap>
    </output>
  </success>

MM Hugue 2018-06-11