Re: defining correctness for an XML transformation - how?

Michael Kay <[email protected]> Thu, 4 Jul 2024 00:23:10 +0100
Newsgroups gmane.text.xml.devel
Message-ID <[email protected]>
--Apple-Mail=_088FA958-4386-4380-B86F-28D918EF0023
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

> If yes, then the way to verify the correctness of an XML-to-XML =
conversion is:
>=20
> Validate the source element against the XML Schema for the source =
element
> Validate the converted target element against the XML Schema for the =
target element
> Create a predicate that the source-target conversion must satisfy and =
evaluate the predicate
> If all predicates return true, then the correctness of the conversion =
is verified
>=20
>=20

It all depends what you mean by "verified". Yes, you have passed all =
your test cases. But you haven't proved that your program is correct, or =
that it will deliver correct results when applied to other cases.=20

In your example there's clearly a disconnect between your narrative =
specification, which says trailing spaces are removed, and your =
predicate (using normalize-space()) which also removes leading spaces =
and multiple internal spaces. Perhaps none of your test cases contains =
leading spaces: so your testing is incomplete. Perhaps the real data =
will never contain leading spaces either. In that case the schema for =
the input is incomplete.

Either way, you haven't verified correctness, you have merely passed =
some tests.

Michael Kay
Saxonica=

--Apple-Mail=_088FA958-4386-4380-B86F-28D918EF0023
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"overflow-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: =
after-white-space;"><div><blockquote type=3D"cite"><div><div =
class=3D"WordSection1" style=3D"page: WordSection1; caret-color: rgb(0, =
0, 0); font-family: Helvetica; font-size: 13px; font-style: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
text-decoration: none;"><div><div><p class=3D"MsoNormal" style=3D"margin: =
0in 0in 8pt; font-size: 12pt; font-family: Aptos, sans-serif; =
line-height: 16.959999px;"><span style=3D"font-size: 11pt; line-height: =
15.546667px; font-family: Calibri, sans-serif;">If yes, then the way to =
verify the correctness of an XML-to-XML conversion =
is:<o:p></o:p></span></p><ol start=3D"1" type=3D"1" =
style=3D"margin-bottom: 0in; margin-top: 0in;"><li class=3D"MsoNormal" =
style=3D"margin: 0in; font-size: 12pt; font-family: Aptos, sans-serif; =
line-height: 16.959999px;"><span style=3D"font-size: 11pt; line-height: =
15.546667px; font-family: Calibri, sans-serif;">Validate the source =
element against the XML Schema for the source =
element<o:p></o:p></span></li><li class=3D"MsoNormal" style=3D"margin: =
0in; font-size: 12pt; font-family: Aptos, sans-serif; line-height: =
16.959999px;"><span style=3D"font-size: 11pt; line-height: 15.546667px; =
font-family: Calibri, sans-serif;">Validate the converted target element =
against the XML Schema for the target element<o:p></o:p></span></li><li =
class=3D"MsoNormal" style=3D"margin: 0in; font-size: 12pt; font-family: =
Aptos, sans-serif; line-height: 16.959999px;"><span style=3D"font-size: =
11pt; line-height: 15.546667px; font-family: Calibri, =
sans-serif;">Create a predicate that the source-target conversion must =
satisfy and evaluate the predicate<o:p></o:p></span></li><li =
class=3D"MsoNormal" style=3D"margin: 0in; font-size: 12pt; font-family: =
Aptos, sans-serif; line-height: 16.959999px;"><span style=3D"font-size: =
11pt; line-height: 15.546667px; font-family: Calibri, sans-serif;">If =
all predicates return true, then the correctness of the conversion is =
verified<o:p></o:p></span></li></ol><p class=3D"MsoNormal" =
style=3D"margin: 0in 0in 8pt; font-size: 12pt; font-family: Aptos, =
sans-serif; line-height: 16.959999px;"><span style=3D"font-size: 11pt; =
line-height: 15.546667px; font-family: Calibri, =
sans-serif;"><br></span></p></div></div></div></div></blockquote><br></div=
><div>It all depends what you mean by "verified". Yes, you have passed =
all your test cases. But you haven't proved that your program is =
correct, or that it will deliver correct results when applied to other =
cases.&nbsp;</div><div><br></div><div>In your example there's clearly a =
disconnect between your narrative specification, which says trailing =
spaces are removed, and your predicate (using normalize-space()) which =
also removes leading spaces and multiple internal spaces. Perhaps none =
of your test cases contains leading spaces: so your testing is =
incomplete. Perhaps the real data will never contain leading spaces =
either. In that case the schema for the input is =
incomplete.</div><div><br></div><div>Either way, you haven't verified =
correctness, you have merely passed some =
tests.</div><div><br></div><div>Michael =
Kay</div><div>Saxonica</div></body></html>=

--Apple-Mail=_088FA958-4386-4380-B86F-28D918EF0023--