下面列出了javax.xml.bind.annotation.adapters.HexBinaryAdapter#org.apache.ws.commons.schema.XmlSchemaElement 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void handleElement(XmlSchemaElement target, XmlSchemaElement source) throws ParserException {
// copy constraints as is
target.getConstraints().addAll(source.getConstraints());
// handle substitution group if present
QName name = source.getSubstitutionGroup();
// check if target schemas don't have the substitution element
if (name != null && targetSchemas.getElementByQName(name) == null) {
final XmlSchemaElement substitute = sourceSchemas.getElementByQName(name);
if (substitute == null) {
throw new ParserException("Missing element in source schemas: " + name);
}
// create a copy in target schemas
createXmlSchemaObjectBase(substitute);
}
handleTypeNameAndType(source.getSchemaTypeName(), source.getSchemaType(),
target::setSchemaTypeName, target::setType);
}
private void addType(QName typeQName, XmlSchemaType type) {
// skip built in xml schema types
if (XML_SCHEMA_NS.equals(typeQName.getNamespaceURI())) {
return;
}
XmlTypeInfo typeInfo = createXmlTypeInfo(typeQName, type);
xmlTypes.put(typeQName, typeInfo);
if (type instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
// process elements nested inside of this element
List<XmlSchemaElement> elements = getNestedElements(complexType);
for (XmlSchemaElement element : elements) {
addNestedElement(element, typeInfo);
}
}
}
/**
* Process each element in the input Schema.
* <p/>
*
* @param xmlSchema the XML schema with COBOL annotations
* @return a map of root elements in the XML schema, each one mapped to its
* composite types constituents
* @throws Xsd2ConverterException if parsing the XML schema fails
*/
public Map < String, RootCompositeType > build(XmlSchema xmlSchema)
throws Xsd2ConverterException {
log.debug("visit XML Schema started");
Map < String, RootCompositeType > rootComplexTypes = new LinkedHashMap < String, RootCompositeType >();
for (Entry < QName, XmlSchemaElement > entry : xmlSchema.getElements()
.entrySet()) {
if (entry.getValue().getSchemaType() instanceof XmlSchemaComplexType) {
CobolAnnotations cobolAnnotations = new CobolAnnotations(
entry.getValue());
XmlSchemaComplexType xsdComplexType = (XmlSchemaComplexType) entry
.getValue().getSchemaType();
RootCompositeType compositeTypes = new RootCompositeType(
cobolAnnotations.getCobolName());
String complexTypeName = getComplexTypeName(xsdComplexType);
rootComplexTypes.put(complexTypeName, compositeTypes);
visit(xsdComplexType, compositeTypes, complexTypeName);
}
}
log.debug("visit XML Schema ended");
return rootComplexTypes;
}
/**
* Contribute array-related properties.
* <p/>
* If this is a array depending on, there must me a corresponding ODO Object
* that we enrich with the array dimensions as the numeric range.
*
* @param xsdElement the xsd element marked as an array
* @param cobolAnnotations the xsd element COBOL annotations
* @param props the corresponding set of properties
*/
@SuppressWarnings("unchecked")
private void addArrayProps(XmlSchemaElement xsdElement,
CobolAnnotations cobolAnnotations, Map < String, Object > props) {
props.put(MIN_OCCURS_PROP_NAME, xsdElement.getMinOccurs());
props.put(MAX_OCCURS_PROP_NAME, xsdElement.getMaxOccurs());
String dependingOn = cobolAnnotations.getDependingOn();
if (dependingOn != null) {
Map < String, Object > depProps = (Map < String, Object >) odoObjects
.get(dependingOn);
depProps.put(MIN_INCLUSIVE_PROP_NAME,
Long.toString(xsdElement.getMinOccurs()));
depProps.put(MAX_INCLUSIVE_PROP_NAME,
Long.toString(xsdElement.getMaxOccurs()));
props.put(DEPENDING_ON_PROP_NAME, odoObjectNames.get(dependingOn));
}
}
void loadSchema(XmlSchema schema) {
XmlSchemaObjectCollection schemaItems = schema.getItems();
// Iterate XML Schema items
for (int i = 0; i < schemaItems.getCount(); i++) {
XmlSchemaObject schemaObject = schemaItems.getItem(i);
NeutralSchema neutralSchema;
if (schemaObject instanceof XmlSchemaType) {
neutralSchema = parse((XmlSchemaType) schemaObject, schema);
} else if (schemaObject instanceof XmlSchemaElement) {
neutralSchema = parseElement((XmlSchemaElement) schemaObject, schema);
} else if (schemaObject instanceof XmlSchemaInclude) {
continue; // nothing to do for includes
} else {
throw new RuntimeException("Unhandled XmlSchemaObject: " + schemaObject.getClass().getCanonicalName());
}
schemas.put(neutralSchema.getType(), neutralSchema);
partialSchemas.clear();
}
}
private void addExceptionMessage(Class<?> cls, XmlSchema schema, XmlSchemaSequence seq) {
try {
//a subclass could mark the message method as transient
Method m = cls.getMethod("getMessage");
if (!m.isAnnotationPresent(XmlTransient.class)
&& m.getDeclaringClass().equals(Throwable.class)) {
JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class);
XmlSchemaElement exEle = new XmlSchemaElement(schema, false);
exEle.setName("message");
exEle.setSchemaTypeName(getTypeName(beanInfo));
exEle.setMinOccurs(0);
seq.getItems().add(exEle);
}
} catch (Exception e) {
//ignore, just won't have the message element
}
}
/**
* Recursively parse through an XmlSchemaPatricle to the elements
* collecting all DidRefSources
*/
private XmlSchemaElement parseParticleForIdentityType(XmlSchemaParticle particle) {
XmlSchemaElement identityType = null;
if (particle != null) {
if (particle instanceof XmlSchemaElement) {
XmlSchemaElement element = (XmlSchemaElement) particle;
String elementName = element.getSchemaTypeName().getLocalPart();
if (elementName.contains(IDENTITY_TYPE)) {
identityType = element;
}
} else if (particle instanceof XmlSchemaSequence) {
XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle;
for (int i = 0; i < schemaSequence.getItems().getCount(); i++) {
XmlSchemaObject item = schemaSequence.getItems().getItem(i);
if (item instanceof XmlSchemaParticle) {
identityType = parseParticleForIdentityType((XmlSchemaParticle) item);
}
}
}
}
return identityType;
}
private XmlSchemaElement createElementType(AST memberNode, XmlSchemaType stype,
Scope fqName) {
// xmlschema:member
XmlSchemaElement member = new XmlSchemaElement(schema, false);
String memberName = memberNode.toString();
member.setName(memberName);
if (stype != null) {
member.setSchemaType(stype);
member.setSchemaTypeName(stype.getQName());
if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
member.setNillable(true);
}
} else {
wsdlVisitor.getDeferredActions().
add(fqName, new ExceptionDeferredAction(member));
}
return member;
}
private XmlSchemaElement createXmlSchemaElement(AST memberNode,
XmlSchemaType schemaType,
Scope fqName) {
// xmlschema:member
XmlSchemaElement member = new XmlSchemaElement(schema, false);
String memberName = memberNode.toString();
member.setName(memberName);
member.setSchemaType(schemaType);
if (schemaType != null) {
member.setSchemaTypeName(schemaType.getQName());
if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
member.setNillable(true);
}
} else {
wsdlVisitor.getDeferredActions().
add(fqName, new StructDeferredAction(member));
}
return member;
}
private Message generateMessage(XmlSchemaElement element, String name) {
Part part = definition.createPart();
part.setName(PART_NAME);
part.setElementName(element.getQName());
Message result = definition.createMessage();
QName qName = new QName(definition.getTargetNamespace(), name);
if (definition.getMessage(qName) != null) {
String newName = getScope().toString() + "." + name;
qName = new QName(definition.getTargetNamespace(), newName);
}
result.setQName(qName);
result.addPart(part);
result.setUndefined(false);
definition.addMessage(result);
return result;
}
/**
* due to a bug, feature, or just plain oddity of JAXB, it isn't good enough
* to just check the form of an element and of its schema. If schema 'a'
* (default unqualified) has a complex type with an element with a ref= to
* schema (b) (default unqualified), JAXB seems to expect to see a
* qualifier, anyway. <br/> So, if the element is local to a complex type,
* all we care about is the default element form of the schema and the local
* form of the element. <br/> If, on the other hand, the element is global,
* we might need to compare namespaces. <br/>
*
* @param element the element.
* @param global if this element is a global element (complex type ref= to
* it, or in a part)
* @param localSchema the schema of the complex type containing the
* reference, only used for the 'odd case'.
* @param elementSchema the schema for the element.
* @return if the element needs to be qualified.
*/
public static boolean isElementQualified(XmlSchemaElement element,
boolean global,
XmlSchema localSchema,
XmlSchema elementSchema) {
QName qn = getElementQualifiedName(element, localSchema);
if (qn == null) {
throw new RuntimeException("isElementQualified on anonymous element.");
}
if (element.isRef()) {
throw new RuntimeException("isElementQualified on the 'from' side of ref=.");
}
if (global) {
return isElementNameQualified(element, elementSchema)
|| (localSchema != null
&& !(qn.getNamespaceURI().equals(localSchema.getTargetNamespace())));
}
return isElementNameQualified(element, elementSchema);
}
@Test
public void testDocLiteralPartWithType() throws Exception {
ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
serviceFactory.setBus(getBus());
serviceFactory.setServiceClass(NoBodyPartsImpl.class);
Service service = serviceFactory.create();
ServiceInfo serviceInfo =
service.getServiceInfos().get(0);
QName qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl",
"operation1");
MessageInfo mi = serviceInfo.getMessage(qname);
qname = new QName("urn:org:apache:cxf:no_body_parts/wsdl",
"mimeAttachment");
MessagePartInfo mpi = mi.getMessagePart(qname);
QName elementQName = mpi.getElementQName();
XmlSchemaElement element =
serviceInfo.getXmlSchemaCollection().getElementByQName(elementQName);
assertNotNull(element);
}
private boolean isReferenceSchemaTypeDefined(QName objectReferenceName,
XmlSchema refSchema) {
List<XmlSchemaObject> schemaObjects = refSchema.getItems();
for (XmlSchemaObject schemaObj : schemaObjects) {
if (schemaObj instanceof XmlSchemaElement) {
XmlSchemaElement el = (XmlSchemaElement)schemaObj;
if (el.getName().equals(objectReferenceName.getLocalPart())) {
return true;
}
}
}
return false;
}
private static XmlSchemaElement findElement(XmlSchema xmlSchema, QName elName) {
XmlSchemaElement schemaElement = null;
schemaElement = xmlSchema.getElementByName(elName);
if (schemaElement == null) {
String prefix = definition.getPrefix(elName.getNamespaceURI());
QName name = new QName(elName.getNamespaceURI(), prefix + ":" + elName.getLocalPart(), prefix);
schemaElement = xmlSchema.getElementByName(name);
}
if (schemaElement != null) {
return schemaElement;
}
for (XmlSchemaExternal ext : xmlSchema.getExternals()) {
if (!(ext instanceof XmlSchemaImport)) {
schemaElement = findElement(ext.getSchema(), elName);
if (schemaElement != null) {
return schemaElement;
}
}
}
return schemaElement;
}
private boolean isWrappableSequence(XmlSchemaComplexType type) {
if (type.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence)type.getParticle();
List<XmlSchemaSequenceMember> items = seq.getItems();
for (XmlSchemaSequenceMember member : items) {
if (!(member instanceof XmlSchemaElement)) {
return false;
}
}
return true;
} else if (type.getParticle() == null) {
return true;
}
return false;
}
private boolean isObjectReference(SchemaCollection schemaList, QName name) {
for (XmlSchema schema : schemaList.getXmlSchemas()) {
XmlSchemaElement element = schema.getElementByName(name);
if (element != null) {
XmlSchemaAnnotation annotation = element.getAnnotation();
if (annotation != null) {
List<XmlSchemaAnnotationItem> annotationColl = annotation.getItems();
for (XmlSchemaAnnotationItem item : annotationColl) {
if (item instanceof XmlSchemaAppInfo) {
return true;
}
}
}
}
}
return false;
}
protected XmlSchemaType lookUpType(Part part) {
XmlSchemaType schemaType = null;
for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
if (part.getElementName() != null) {
XmlSchemaElement schemaElement = xmlSchema.getElementByName(part.getElementName());
if (schemaElement != null) {
schemaType = schemaElement.getSchemaType();
}
} else {
if (part.getTypeName() != null) {
schemaType = xmlSchema.getTypeByName(part.getTypeName());
}
}
if (schemaType != null) {
return schemaType;
}
}
return schemaType;
}
protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(),
getQualifyWrapperSchema());
XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
if (e != null) {
mpi.setXmlSchema(e);
return;
}
XmlSchema schema = si.getSchema();
si.setElement(null); //cached element is now invalid
XmlSchemaElement el = new XmlSchemaElement(schema, true);
el.setName(mpi.getElementQName().getLocalPart());
el.setNillable(true);
XmlSchemaType tp = (XmlSchemaType)mpi.getXmlSchema();
if (tp == null) {
throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG,
mpi.getName(),
mpi.getMessageInfo().getName()));
}
el.setSchemaTypeName(tp.getQName());
mpi.setXmlSchema(el);
}
private boolean getElementQualification(XmlSchemaElement element, String uri) {
QName schemaName = element.getQName();
if (element.isRef()) {
schemaName = element.getRef().getTargetQName();
}
if (schemaName.getNamespaceURI().isEmpty()) {
schemaName = new QName(uri, schemaName.getLocalPart());
}
boolean qualified = false;
if (element.getForm() == XmlSchemaForm.QUALIFIED) {
qualified = true;
} else {
qualified = WSDLUtils.isElementFormQualified(xmlSchemaList, schemaName);
}
return qualified;
}
@Override
public void writeSchema(XmlSchema root) {
XmlSchemaComplexType complex = new XmlSchemaComplexType(root, true);
complex.setName(getSchemaType().getLocalPart());
XmlSchemaSequence sequence = new XmlSchemaSequence();
complex.setParticle(sequence);
AegisType kType = getKeyType();
AegisType vType = getValueType();
XmlSchemaElement element = new XmlSchemaElement(root, false);
sequence.getItems().add(element);
element.setName(getEntryName().getLocalPart());
element.setMinOccurs(0);
element.setMaxOccurs(Long.MAX_VALUE);
XmlSchemaComplexType evType = new XmlSchemaComplexType(root, false);
element.setType(evType);
XmlSchemaSequence evSequence = new XmlSchemaSequence();
evType.setParticle(evSequence);
createElement(root, evSequence, getKeyName(), kType, false);
createElement(root, evSequence, getValueName(), vType, true);
}
private static boolean hasResultRowName(XmlSchemaComplexType wrapperSchemaComplexType) {
XmlSchemaParticle wrapperSchemaParticle = wrapperSchemaComplexType.getParticle();
// a single sequence must be there
if (!(wrapperSchemaParticle instanceof XmlSchemaSequence)) {
return false;
}
XmlSchemaSequence wrapperSchemaSequence = (XmlSchemaSequence) wrapperSchemaParticle;
XmlSchemaObjectCollection objects = wrapperSchemaSequence.getItems();
if (objects.getCount() != 1) {
return false;
}
XmlSchemaObject schemaObject = objects.getItem(0);
if (!(schemaObject instanceof XmlSchemaElement)) {
return false;
}
XmlSchemaElement schemaElement = (XmlSchemaElement) schemaObject;
if (!((((XmlSchemaComplexType) schemaElement.getSchemaType())
.getParticle()) instanceof XmlSchemaSequence)) {
return false;
}
// cannot contain any attributes
if (wrapperSchemaComplexType.getAttributes().getCount() > 0) {
return false;
}
return true;
}
/**
* This copes with an observed phenomenon in the schema built by the
* ReflectionServiceFactoryBean. It is creating element such that: (a) the
* type is not set. (b) the refName is set. (c) the namespaceURI in the
* refName is set empty. This apparently indicates 'same Schema' to everyone
* else, so thus function implements that convention here. It is unclear if
* that is a correct structure, and it if changes, we can simplify or
* eliminate this function.
*
* @param name
* @param referencingURI
*/
public static XmlSchemaElement findElementByRefName(SchemaCollection xmlSchemaCollection,
QName name,
String referencingURI) {
String uri = name.getNamespaceURI();
if ("".equals(uri)) {
uri = referencingURI;
}
QName copyName = new QName(uri, name.getLocalPart());
XmlSchemaElement target = xmlSchemaCollection.getElementByQName(copyName);
assert target != null;
return target;
}
public XmlSchemaElement extract(QName name, XmlSchemaType type) throws ParserException {
// find target schema
final XmlSchema targetSchema = getOrCreateTargetSchema(name.getNamespaceURI());
// create new element in target schema
final XmlSchemaElement result = new XmlSchemaElement(targetSchema, true);
result.setName(name.getLocalPart());
// set element type to the provided type
final QName typeQName = type.getQName();
withNamespace(typeQName.getNamespaceURI(), () -> setTargetTypeQName(typeQName, result::setSchemaTypeName));
return result;
}
@Test
public void testCharMappings() throws Exception {
defaultContext();
BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
type.setTypeClass(SimpleBean.class);
type.setTypeMapping(mapping);
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("SimpleBean");
XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
boolean charok = false;
for (int x = 0; x < seq.getItems().size(); x++) {
XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("character".equals(oe.getName())) {
charok = true;
assertNotNull(oe.getSchemaTypeName());
assertTrue(oe.isNillable());
assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME,
oe.getSchemaTypeName());
}
}
}
assertTrue(charok);
}
private void sortItems(final XmlSchemaSequence seq, final String[] propertyOrder) {
final List<String> propList = Arrays.asList(propertyOrder);
Collections.sort(seq.getItems(), new Comparator<XmlSchemaSequenceMember>() {
public int compare(XmlSchemaSequenceMember o1, XmlSchemaSequenceMember o2) {
XmlSchemaElement element1 = (XmlSchemaElement)o1;
XmlSchemaElement element2 = (XmlSchemaElement)o2;
int index1 = propList.indexOf(element1.getName());
int index2 = propList.indexOf(element2.getName());
return index1 - index2;
}
});
}
private Long parseParticleForMinOccurs(XmlSchemaParticle particle, String naturalKeyElement) {
Long minOccurs = null;
if (particle != null) {
if (particle instanceof XmlSchemaElement) {
XmlSchemaElement element = (XmlSchemaElement) particle;
String elementName = element.getName();
if (elementName.equals(naturalKeyElement)) {
minOccurs = element.getMinOccurs();
return minOccurs;
}
} else if (particle instanceof XmlSchemaSequence) {
XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle;
for (int i = 0; i < schemaSequence.getItems().getCount(); i++) {
XmlSchemaObject item = schemaSequence.getItems().getItem(i);
if (item instanceof XmlSchemaParticle) {
minOccurs = parseParticleForMinOccurs((XmlSchemaParticle) item, naturalKeyElement);
if(minOccurs != null) {
return minOccurs;
}
}
}
}
}
return minOccurs;
}
private static XmlElementInfo createXmlElementInfo(QName qname, QName xmlType, XmlSchemaElement element) {
XmlElementInfo elementInfo = new XmlElementInfo();
elementInfo.qname = qname;
elementInfo.xmlType = xmlType;
elementInfo.minOccurs = element.getMinOccurs();
elementInfo.maxOccurs = element.getMaxOccurs();
elementInfo.nillable = element.isNillable();
return elementInfo;
}
protected void validateTargetSchemas(XmlSchemaElement testElement) throws XmlSchemaSerializer.XmlSchemaSerializerException, IOException, SAXException {
final String testNamespace = testElement.getQName().getNamespaceURI();
final XmlSchema[] schemas = xmlSchemaExtractor.getTargetSchemas().getXmlSchemas();
for (XmlSchema targetSchema : schemas) {
final String targetNamespace = targetSchema.getTargetNamespace();
// skip XSD and XML namespaces, which break in StaxUtils.toString below
if (targetNamespace.equals(XMLConstants.XML_NS_URI) || targetNamespace.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
continue;
}
final Document schemaDocument = targetSchema.getSchemaDocument();
if (targetNamespace.isEmpty()) {
// remove invalid xmlns:tns="" attribute or it breaks StaxUtils.toString below
schemaDocument.getDocumentElement().removeAttribute("xmlns:tns");
}
final String schemaString = StaxUtils.toString(schemaDocument);
// validate against schema XSD
XmlSchemaTestHelper.validateSchema(schemaString);
if (testNamespace.equals(targetNamespace)) {
// must have element in test namespace
assertThat(targetSchema.getElements()).isNotEmpty();
}
// all schemas must not be empty
assertThat(targetSchema.getItems()).isNotEmpty();
// check that all targetSchema types and elements are present in sourceSchema
final List<Element> sourceNodes = sourceSchemaNodes.get(targetNamespace);
if (sourceNodes == null) {
if (!targetNamespace.equals(testElement.getQName().getNamespaceURI())) {
fail("Unexpected missing source schema " + targetNamespace);
}
} else {
XmlSchemaTestHelper.checkSubsetSchema(schemaDocument, sourceNodes);
}
}
}
private void createTypeImportingElement(XmlSchema importingSchema) {
XmlSchemaComplexType typeWithElementRef = new XmlSchemaComplexType(importingSchema, true);
typeWithElementRef.setName("typeWithRef");
XmlSchemaSequence sequence = new XmlSchemaSequence();
typeWithElementRef.setParticle(sequence);
XmlSchemaElement refElement = new XmlSchemaElement(importingSchema, false);
refElement.getRef().setTargetQName(new QName(ELEMENT_SCHEMA, "importedElement"));
}
/**
* Create an XML Schema element from a COBOL data item.
*
* @param xsdDataItem COBOL data item decorated with XSD attributes
* @return the XML schema element
*/
public XmlSchemaElement createXmlSchemaElement(final XsdDataItem xsdDataItem) {
// Let call add root elements if he needs to so for now pretend this is
// not a root element
XmlSchemaElement element = new XmlSchemaElement(getXsd(), false);
element.setName(xsdDataItem.getXsdElementName());
if (xsdDataItem.getMaxOccurs() != 1) {
element.setMaxOccurs(xsdDataItem.getMaxOccurs());
}
if (xsdDataItem.getMinOccurs() != 1) {
element.setMinOccurs(xsdDataItem.getMinOccurs());
}
/*
* Create this element schema type, then if its a simple type set it as
* an anonymous type. Otherwise, it is a named complex type, so
* reference it by name.
*/
XmlSchemaType xmlSchemaType = createXmlSchemaType(xsdDataItem);
if (xmlSchemaType == null) {
return null;
}
if (xmlSchemaType instanceof XmlSchemaSimpleType) {
element.setSchemaType(xmlSchemaType);
} else {
element.setSchemaTypeName(xmlSchemaType.getQName());
}
if (getConfig().addLegStarAnnotations()) {
element.setAnnotation(_annotationEmitter
.createLegStarAnnotation(xsdDataItem));
}
return element;
}