Joel, Hello. Here are some attempts at answering several of your questions.
> -1- is there any way to have the tool add the xml preamble (e.g. <?xml > version="1.0" encoding="UTF-8" standalone="yes"?>), or do I have to insert > it before exporting? You could consider copying the `parse` function in a module generated by `generateDS.py` with the "-o" command line option. You'd copy it to a separate module/script and then modify it however you want, for example, adding your custom xml preamble. For example, after running: $ generateDS.py -o mymodule.py myschema.xsd you might write a module: import sys import mymodule def get_root_tag(node): tag = Tag_pattern_.match(node.tag).groups()[-1] rootClass = GDSClassesMapping.get(tag) if rootClass is None: rootClass = globals().get(tag) return tag, rootClass def parse(inFileName, silence=False): parser = None doc = parsexml_(inFileName, parser) rootNode = doc.getroot() rootTag, rootClass = get_root_tag(rootNode) if rootClass is None: rootTag = 'mailboxType' rootClass = mailboxType rootObj = rootClass.factory() rootObj.build(rootNode) # Enable Python to collect the space used by the DOM. doc = None if not silence: # # Add my custom XML preamble here: # #sys.stdout.write('<?xml version="1.0" ?>\n') sys.stdout.write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n') rootObj.export( sys.stdout, 0, name_=rootTag, namespacedef_='', pretty_print=True) return rootObj def test(): rootObj = parse("my_xml_instance_doc.xml") o o o test() Note how I've modified the call to `sys.stdout.write` to write out your XML preamble. Would that technique work for you? > -2- is there any way to get rid of one of the namespaces by declaring it > the default namespace? ( xmlns="http://...") This one I don't understand. But, with my dim and weak grasp of namespaces, that's to be expected. > -3- is there any integrated way I missed, to specifiy schema locations? Does command line option -c do what you need? From the help (produced with `generateDS.py --help`): -c <xmlcatalogfilename> Input file name to load an XML catalog You can look in `process_includes.py` to try to figure out how that is used. Search for "catalog". There is actually a unit test for this (in `generateds/tests`), but it appears empty to me. So, if this is the feature you need, and it does not work as you'd expect it, please let me know so that I can try to fix it. Here is some documentation on XML catalogs that I've found on the Web: - https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html - https://xerces.apache.org/xerces2-j/faq-xcatalogs.html. - https://www.oxygenxml.com/doc/versions/20.1/ug-editor/topics/using-XML-Catalogs.html Hope this helps. Dave On Wed, Oct 10, 2018 at 02:54:27PM +0200, Joel Thill wrote: > Hi Dave, > > I've just recently discovered your tool, and appreciate a lot the economies > and readability improvements I could achieve : from my old source code > variant based on xmlx to the new one based on your tool, I've shrunk my > code down to 35%. > > Still, I'm struggling with 3 issues and was wondering if you could maybe > help me: > > -1- is there any way to have the tool add the xml preamble (e.g. <?xml > version="1.0" encoding="UTF-8" standalone="yes"?>), or do I have to insert > it before exporting? > -2- is there any way to get rid of one of the namespaces by declaring it > the default namespace? ( xmlns="http://...") > -3- is there any integrated way I missed, to specifiy schema locations? > > cheers. > joel. -- Dave Kuhlman http://www.davekuhlman.org _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users