'Get the structure of the resource
@param options: include option lists in option fields
@param references: include option lists even for reference fields
@param stylesheet: the stylesheet to use for transformation
@param as_json: convert into JSON after transformation'

def export_struct(self, meta=False, options=False, references=False, stylesheet=None, as_json=False, as_tree=False):

    xml = current.xml
    root = etree.Element(xml.TAG.root)
    main = xml.get_struct(self.prefix, self.name, alias=self.alias, parent=root, meta=meta, options=options, references=references)
    for component in self.components.values():
        prefix = component.prefix
        name = component.name
        xml.get_struct(prefix, name, alias=component.alias, parent=main, meta=meta, options=options, references=references)
    tree = etree.ElementTree(root)
    if (stylesheet is not None):
        args = dict(domain=xml.domain, base_url=current.response.s3.base_url, prefix=self.prefix, name=self.name, utcnow=s3_format_datetime())
        tree = xml.transform(tree, stylesheet, **args)
        if (tree is None):
            return None
    if as_tree:
        return tree
    if as_json:
        return xml.tree2json(tree, pretty_print=True)
    else:
        return xml.tostring(tree, pretty_print=True)
