Rob,
>...Does the CUSRSORTOXML function take an XSD file as a parameter and use it to create the XML output? I tried the following code, but it overwrites the XSD.
No. As you discovered, you will overwrite any existing XSD if you specify the XSD name as the 6th parameter of CURSORTOXML. However, you can succeed in adding a reference to the existing XSD by making the 6th param "" and adding a 7th param (cSchemaLocation) set to "Testxml.xsd". This prevents the creation of the XSD, but adds a ref to it at the top of the XML.
>What am I doing wrong, or doesn't this function work as I anticipated? If not, how should I approach creating the XML to conform to the client's XSD? Can someone point me in the correct direction or provide a simple example?
My comments above do not, however, take care of your desire to create XML to conform to the client's XSD. For that, you might have to do some STRTRANning after the fact, use XMLAdapter (specially configured to override the default root, table and field tag names), or use string concatenation or TEXTMERGE or any of several techniques to walk through the table and construct the XML yourself in the proper format.
Perhaps you could post a sample of the XML and the XSD you are trying to match it with? Can't really help you further without those.