Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from lxml import etree
- import sys
- file = sys.argv[1]
- if not file:
- print("usage: {} <XSD-or-WSDL-path>".format(sys.argv[0]))
- exit()
- def main():
- print("input file: {}".format(file))
- tree = etree.parse(file)
- for el in tree.xpath("//*[local-name() = 'schema']"):
- tnss = el.xpath("@targetNamespace")[0].split("/")[-2]
- print("processing {} ...".format(tnss))
- ofn = "{}.xsd".format(tnss)
- with open(ofn, "wb") as of:
- of.write(etree.tostring(el, encoding="utf-8", xml_declaration="1.0"))
- print("file {} written successfully".format(ofn))
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement