Depending upon the complexity and size of the XML Schema, this can be relatively very easy or very difficult. You first should analyze the XML Schema and the requirements for the actual XML document that you need to create. Once you cleary understand the XML document structure that is required, you then would check to see if it is valid according to the provided XML Schema. If it is, then you are ready to write code.
When you write the code to create the XML document, you need to write the code to produce the XML document correctly, i.e. a valid XML document that will conform to the rules in the XML Schema. The one check that
you should implement is once [the code] has created the document, [the code] should validate against the XML schema to ensure that the document is valid and has been created correctly.