XMLSplitterSerialisationHelper { public static Element typeDescriptorToExtensionXML(TypeDescriptor descriptor) { Element result = new Element("extensions", XScuflNS); Element type = null; if (descriptor instanceof ComplexTypeDescriptor) { type = constructElementForComplexType( (ComplexTypeDescriptor) descriptor, new ArrayList<String>()); } else if (descriptor instanceof ArrayTypeDescriptor) { type = constructElementForArrayType( (ArrayTypeDescriptor) descriptor, new ArrayList<String>()); } result.addContent(type); return result; }  static Element typeDescriptorToExtensionXML(TypeDescriptor descriptor); static TypeDescriptor extensionXMLToTypeDescriptor(Element element); final static Namespace XScuflNS; }
@Test public void testCyclicToElement() throws Exception { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("typename"); a.setQnameFromString("{namespace}typename"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("typename2"); b.setQnameFromString("{namespace}typename2"); a.getElements().add(b); b.getElements().add(a); Element el = XMLSplitterSerialisationHelper .typeDescriptorToExtensionXML(a); String xml = new XMLOutputter().outputString(el); assertEquals( "unexpected xml", "<s:extensions xmlns:s=\"http: xml); }
@Test public void testCyclicToElement2() throws Exception { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("typename"); a.setQnameFromString("{namespace}typename"); a.getElements().add(a); Element el = XMLSplitterSerialisationHelper .typeDescriptorToExtensionXML(a); String xml = new XMLOutputter().outputString(el); assertEquals( "unexpected xml", "<s:extensions xmlns:s=\"http: xml); }