private void addAnnotationToDefinition(Element definitionElement, QName qname) { addAnnotationToDefinition(definitionElement, qname, null); }
/** * Adds XSD element definition. * @param name element QName * @param typeName element type QName * @param parent element under which the definition will be added */ private Element addElementDefinition(QName name, QName typeName, int minOccurs, int maxOccurs, Element parent) { Element elementDef = createElement(new QName(W3C_XML_SCHEMA_NS_URI, "element")); parent.appendChild(elementDef); if (isMyNamespace(name)) { setAttribute(elementDef, "name", name.getLocalPart()); if (typeName.equals(DOMUtil.XSD_ANY)) { addSequenceXsdAnyDefinition(elementDef); } else { setQNameAttribute(elementDef, "type", typeName); } } else { // Need to create "ref" instead of "name" setAttribute(elementDef, "ref", name); if (typeName != null) { // Type cannot be stored directly, XSD does not allow it with "ref"s. addAnnotationToDefinition(elementDef, A_TYPE, typeName); } } setMultiplicityAttribute(elementDef, "minOccurs", minOccurs); setMultiplicityAttribute(elementDef, "maxOccurs", maxOccurs); return elementDef; }
/** * Adds XSD definitions from PropertyContainerDefinition. This is complexType and element. * If the property container is an ResourceObjectDefinition, it will add only annotated * complexType definition. * * @param definition PropertyContainerDefinition to process * @param parent element under which the XSD definition will be added */ private void addContainerDefinition(PrismContainerDefinition definition, Element elementParent, Element complexTypeParent) { ComplexTypeDefinition complexTypeDefinition = definition.getComplexTypeDefinition(); if (complexTypeDefinition != null && // Check if the complex type is a top-level complex type. If it is then it was already processed and we can skip it schema.findComplexTypeDefinition(complexTypeDefinition.getTypeName()) == null && // If the definition is not in this schema namespace then skip it. It is only a "ref" getNamespace().equals(complexTypeDefinition.getTypeName().getNamespaceURI()) ) { addComplexTypeDefinition(complexTypeDefinition,complexTypeParent); } Element elementElement = addElementDefinition(definition.getName(), definition.getTypeName(), definition.getMinOccurs(), definition.getMaxOccurs(), elementParent); if (complexTypeDefinition == null || !complexTypeDefinition.isContainerMarker()) { // Need to add a:container annotation to the element as the complex type does not have it addAnnotationToDefinition(elementElement, A_PROPERTY_CONTAINER); } }