11# Comparing XML
22
33A simple XML comparison can be performed using
4- @scaladoc [ ` XmlCompare.compare ` ] ( software.purpledragon.xml.compare.XmlCompare$ ) :
4+ @scaladoc [ XmlCompare.compare] ( software.purpledragon.xml.compare.XmlCompare$ ) :
55
66``` scala
77// using XML literals:
@@ -11,8 +11,8 @@ val result = XmlCompare.compare(<test/>, <test/>) // == XmlEqual
1111val success = XmlCompare .compare(<result ><success /></result >, XML .loadFile(" result.xml" ))
1212```
1313
14- The way that XML is compared can be customised by supplying a ` Set ` of
15- @scaladoc [ ` DiffOption ` s ] ( software.purpledragon.xml.compare.options.DiffOption$ ) :
14+ The way that XML is compared can be customised by supplying
15+ @scaladoc [ DiffOptions ] ( software.purpledragon.xml.compare.options.DiffOptions ) :
1616
1717``` scala
1818// this would result an XmlEqual
@@ -24,16 +24,16 @@ XmlCompare.compare(
2424XmlCompare .compare(
2525 <test name =" John" age =" 45" />,
2626 <test age =" 45" name =" John" />,
27- Set (DiffOption .StrictAttributeOrdering ))
27+ DiffOptions (DiffOption .StrictAttributeOrdering ))
2828```
2929
3030@ref :[ Comparison Options] ( #comparison-options ) contains details of the supported options.
3131
3232## Comparison Results
3333
34- ` XmlCompare.compare ` returns an @scaladoc [ ` XmlDiff ` ] ( software.purpledragon.xml.compare.XmlDiff ) that will either be
35- @scaladoc [ ` XmlEqual ` ] ( software.purpledragon.xml.compare.XmlEqual ) or a detailed
36- @scaladoc [ ` XmlDiffers ` ] ( software.purpledragon.xml.compare.XmlDiffers ) . If a simple
34+ ` XmlCompare.compare ` returns an @scaladoc [ XmlDiff] ( software.purpledragon.xml.compare.XmlDiff ) that will either be
35+ @scaladoc [ XmlEqual] ( software.purpledragon.xml.compare.XmlEqual ) or a detailed
36+ @scaladoc [ XmlDiffers] ( software.purpledragon.xml.compare.XmlDiffers ) . If a simple
3737pass/fail check is required then the ` isEqual ` method can be called on the result.
3838
3939### XmlEqual
@@ -59,16 +59,33 @@ XmlDiffers(
5959
6060## Comparison Options
6161
62- By default the following options are used:
62+ ### Building Options
63+
64+ Options can built by either passing them into
65+ @scaladoc [ DiffOptions()] ( software.purpledragon.xml.compare.options.DiffOptions ) ) or by combining them:
66+
67+ ``` scala
68+ // these two are equivalent:
69+ DiffOptions (DiffOption .IgnoreNamespacePrefix , DiffOption .IgnoreNamespace )
70+ DiffOptions (DiffOption .IgnoreNamespacePrefix ) & DiffOption .IgnoreNamespace
71+ ```
72+
73+
74+ ### Default Options
75+
76+ The default options (unspecified or
77+ @scaladoc [ DiffOptions.default] ( software.purpledragon.xml.compare.options.DiffOptions$ ) ) are:
6378
6479* ` IgnoreNamespacePrefix `
6580
66- ### IgnoreNamespacePrefix
81+ ### Available Options
82+
83+ #### IgnoreNamespacePrefix
6784
6885If enabled the prefixes associated with namespaces will be ignored. Differing namespaces will still cause a comparison
6986error.
7087
71- #### Example
88+ ##### Example
7289
7390This:
7491``` xml
@@ -80,11 +97,11 @@ would be considered equal to:
8097<f : example xmlns : f =" http://example.com" >5</f : example >
8198```
8299
83- ### IgnoreNamespace
100+ #### IgnoreNamespace
84101
85102If enabled then namespaces will be ignored completely.
86103
87- #### Example
104+ ##### Example
88105
89106This:
90107``` xml
@@ -96,12 +113,12 @@ would be considered equal to:
96113<f : example xmlns : f =" http://example.org" >5</f : example >
97114```
98115
99- ### StrictAttributeOrdering
116+ #### StrictAttributeOrdering
100117
101118This adds an additional comparison on the ordering of element attributes. The presence of attributes will be checked
102119_ before_ the ordering.
103120
104- #### Example
121+ ##### Example
105122
106123This:
107124
@@ -126,14 +143,14 @@ XmlDiffers(
126143)
127144```
128145
129- ### IgnoreChildOrder
146+ #### IgnoreChildOrder
130147
131148If enabled the ordering of child elements will be ignored. This is handled by re-ordering child nodes using an arbitrary
132149sorting algorithm before comparing them.
133150
134151_ Note: the first difference returned may be different if this option is enabled._
135152
136- #### Example 1
153+ ##### Example 1
137154
138155This:
139156
@@ -152,7 +169,7 @@ would be considered equal to:
152169</example >
153170```
154171
155- #### Example 2
172+ ##### Example 2
156173
157174This:
158175
0 commit comments