SchemaElement { public static OMElement createElement(final OMElement piElement, final ISchemaReference data) { final OMFactory f = piElement.getOMFactory(); final OMElement schema = f.createOMElement(Q_ELEMENT_NAME, piElement); schema.addAttribute(LN_ATTR_LOCATION, data.getLocation(), null); final String version = data.getVersion(); if ( version != null && !version.isEmpty()) schema.addAttribute(LN_ATTR_VERSION, version, null); final String namespace = data.getNamespace(); if ( namespace != null && !namespace.isEmpty()) schema.addAttribute(LN_ATTR_NAMESPACE, namespace, null); return schema; }  static OMElement createElement(final OMElement piElement, final ISchemaReference data); static OMElement getElement(final OMElement piElement); static SchemaReference readElement(final OMElement siElement); static final QName Q_ELEMENT_NAME; static final String LN_ATTR_LOCATION; static final String LN_ATTR_VERSION; static final String LN_ATTR_NAMESPACE; }
@Test public void testCreateElement() throws Exception { SchemaReference schema = new SchemaReference(); schema.setLocation("somewhere"); schema.setNamespace("namespace1"); schema.setVersion("test"); OMElement schemaElement = SchemaElement.createElement(createParent(), schema); assertNotNull(schemaElement); assertEquals(SCHEMA_ELEMENT_NAME, schemaElement.getQName()); assertEquals(schema.getLocation(), schemaElement.getAttributeValue(new QName("location"))); assertEquals(schema.getNamespace(), schemaElement.getAttributeValue(new QName("namespace"))); assertEquals(schema.getVersion(), schemaElement.getAttributeValue(new QName("version"))); }