예제 #1
0
    def map(cls, element: AnyElement) -> List[Class]:
        """Map schema children elements to classes."""

        assert element.qname is not None

        target_namespace, module = split_qname(element.qname)
        target = cls.build_class(element, target_namespace)

        return list(ClassUtils.flatten(target, module))
예제 #2
0
    def test_flatten(self):
        target = ClassFactory.create(
            qname="{xsdata}root", attrs=AttrFactory.list(3), inner=ClassFactory.list(2)
        )

        for attr in target.attrs:
            attr.types.extend([x.clone() for x in attr.types])
            for tp in attr.types:
                tp.forward = True

        result = ClassUtils.flatten(target, "xsdata")
        actual = list(result)

        self.assertIsInstance(result, Generator)
        self.assertEqual(3, len(actual))

        for obj in actual:
            self.assertEqual("xsdata", obj.module)

        for attr in target.attrs:
            self.assertEqual(1, len(attr.types))
            self.assertFalse(attr.types[0].forward)
예제 #3
0
파일: dict.py 프로젝트: neriusmika/xsdata
    def map(cls, data: Dict, name: str) -> List[Class]:
        """Convert a dictionary to a list of codegen classes."""

        target = cls.build_class(data, name)
        return list(ClassUtils.flatten(target, name))