[xsl] ChatGPT results are "subject to review"

Subject: [xsl] ChatGPT results are "subject to review"
From: "Dorothy Hoskins dorothy.hoskins@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 6 Jul 2023 15:45:37 -0000
I recently ran a small exercise in ChatGPT. I provided it a sample input
and output that would require it to put text from a footnote in XML input
and insert it a popup-enabled span in the HTML output where the footnote
reference number appeared in the source XML.
The first stylesheet generated in the results returned was written in XSLT
1, as I forgot to prompt for an XSLT verion.
I asked ChatGPT to rewrite in XSLT 2, taking advantage of any XSLT 2
features that would improve the efficiency of the transform, which it did
and explained what it did.
Then I asked for a version 3 XSLT and got that with some new function, so
now I can compare how the same transformation concept was treated in the
XSLT versions.
ChatGPT included comments in each XSLT and its own explanation for the
templates in the text thread about the XSLT. Seems like a good learning
tool, although all generated code must be reviewed and tested to see if the
results are indeed the same output.
Along the way, I saw that ChatGPT had thrown in a concat() when building a
text string for an attribute. When I prompted ChatGPT to explain why it
included the concat(), it apologized and said the concat() wasn't
necessary, regenerated the previous XSLT and explained its reason for the
change.
Obviously, a person who doesn't look closely at the generated code, or
doesn't know much XSLT, might not have seen the concat() as an issue. So
user beware.
>From what I understand, I could try the exact same prompt with sample
inputs and outputs and might be given a different result, but I haven't
done that investigation yet.
Other observation from trying out XML in ChatGPT: it can check
well-formedness but had problems discerning the XML declaration and the
root element when there wasn't a line break between them, so it incorrectly
stated that there was no root elements and produced a default <document>
root and put all the rest of the XML elements into it to retain the
hierarchy. It also generated a partial XML result with comments about where
more XML elements occurred, rather than providing the entire XML tree in
the generated XML it "corrected".
It is capable of generating a schema, a schematron and an Xspec from sample
XML, all of which would require testing, but it sure is fast. A quick way
to create stubs for future development.
I think if someone invested in a training set for a specific schema with a
bunch of examples, it would be a great tool for XML/XSLT development,
always "subject to review".
Regards, Dorothy

Current Thread