def xmlstub(model, example=False):
    """
    Write the model data to a XML file wrapped with a root element and 
    namespace declarations. 
    """
    print('Writing data instance for ', model, ' to stub.xml')
    with open('stub.xml', 'w') as f:
        f.write(
            """<?xml version='1.0' encoding='UTF-8'?>
    <s3m:root xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:s3m="https://www.s3model.com/ns/s3m/"
      targetNamespace="https://www.s3model.com/ns/s3m/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation='https://www.s3model.com/ns/s3m/ stub.xsd'
    >
    
    """
            )
        f.write(model.getXMLInstance(example))
        f.write('</s3m:root>\n')
