String toString( XSComplexTypeDefinition complexType ) { String s = "\n - complex type: '" + complexType.getName() + "' (" + complexType.getNamespace() + ")"; XSObjectList attributeUses = complexType.getAttributeUses(); for ( int i = 0; i < attributeUses.getLength(); i++ ) { XSAttributeUse attributeUse = (XSAttributeUse) attributeUses.item( i ); s += "\n - attribute: " + attributeUse.getAttrDeclaration().getName(); XSTypeDefinition baseType = complexType.getBaseType(); if ( baseType != null ) { s += "\n - type hierarchy:"; switch ( complexType.getContentType() ) { case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: { s += "element only"; XSParticle particle = complexType.getParticle(); s += generateParticleHierarchy( particle, " " ); break; XSParticle particle = complexType.getParticle(); s += generateParticleHierarchy( particle, " " ); break;
public JBossXSComplexTypeDefinition(XSComplexTypeDefinition xc) { super(xc.getName(),xc.getNamespace()); setAnonymous(xc.getAnonymous()); xspart = xc.getParticle(); xsSimple = xc.getSimpleType(); deriveMethod = xc.getDerivationMethod(); this.baseType = new JBossXSTypeDefinition(xc.getBaseType()); }
private boolean isCycle( XSComplexTypeDefinition typeDef, List<XSElementDeclaration> parentEls, List<XSComplexTypeDefinition> parentCTs ) { if ( typeDef.getName() != null ) { for ( XSComplexTypeDefinition ct : parentCTs ) { if ( ct.getName() != null ) { if ( typeDef.getName().equals( ct.getName() ) && typeDef.getNamespace().equals( ct.getNamespace() ) ) { handleCycle( parentEls, parentCTs ); return true; } } } } return false; }
public static boolean isComplexTypeDerivedFromSTList(XSComplexTypeDefinition complexTypeDef, short derivationMethod) { XSTypeDefinition baseType = complexTypeDef.getBaseType(); return complexTypeDef.getDerivationMethod() == derivationMethod && baseType instanceof XSSimpleTypeDefinition && ((XSSimpleTypeDefinition)baseType).getVariety() == XSSimpleTypeDefinition.VARIETY_LIST; } // isComplexTypeDerivedFromSTList
ArrayList<XSComplexTypeDefinition> toAdd ) throws Exception { if (!nsdMap.containsKey(def.getNamespace())) { Util.log("Namespace desc not found for: " + def); td = new TypeDesc(def.getName(), def.getNamespace(), typeName, TypeDesc.TypeEnum.CLASS); XSObjectList anns = def.getAnnotations(); td.documentation = parseAnnotationString( "Type " + def.getNamespace() + ":" + def.getName() + " documentation", anns != null && anns.getLength() > 0 ? ((XSAnnotation) anns.item(0)).getAnnotationString() : null ); TypeDesc tdBase = null; if (checkComplexType(def.getBaseType())) { XSComplexTypeDefinition base = (XSComplexTypeDefinition) def.getBaseType(); String typeNameBase = toJavaTypeName(base, nsdMap); if ((tdBase = jtMap.get(model.toJavaQualifiedTypeName(base, nsdMap, false))) == null) { tdBase = new TypeDesc(base.getName(), base.getNamespace(), typeNameBase, TypeDesc.TypeEnum.CLASS); jtMap.put(model.toJavaQualifiedTypeName(base, nsdMap, false), tdBase); if (def.getSimpleType() != null || def.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED) { FieldDesc fd = new FieldDesc(FieldDesc.SIMPLE, "value", "String", null, "null", true); fd.realIndex = td.fdMap.size(); td.fdMap.put(fd.name, fd); XSObjectList attrs = def.getAttributeUses(); for (int i = 0; i < attrs.getLength(); i++) { XSAttributeUse au = (XSAttributeUse) attrs.item(i);
if ( typeDef.getContentType() != CONTENTTYPE_EMPTY && typeDef.getContentType() != CONTENTTYPE_ELEMENT ) { if ( typeDef.getSimpleType() != null ) { pt = new PrimitiveType( typeDef.getSimpleType() ); XSObjectList attributeUses = typeDef.getAttributeUses(); for ( int i = 0; i < attributeUses.getLength(); i++ ) { XSAttributeUse attrUse = ( (XSAttributeUse) attributeUses.item( i ) ); XSParticle particle = typeDef.getParticle(); if ( particle != null ) { List<Mapping> childElMappings = generateMapping( particle, 1, mc, parentEls, parentCTs );
LOG.debug( "Exporting complex type, name: " + complex.getName() ); if ( !complex.getAnonymous() ) { writer.writeAttribute( "name", complex.getName() ); short contentType = complex.getContentType(); short derivation = complex.getDerivationMethod(); XSTypeDefinition base = complex.getBaseType(); case DERIVATION_LIST: LOG.warn( "Exporting derivation by list is not implemented. Occured for complex element " + complex.getName() ); break; case DERIVATION_NONE: case DERIVATION_SUBSTITUTION: LOG.warn( "Exporting derivation by substitution is not implemented. Occured for complex element " + complex.getName() ); break; case DERIVATION_UNION: LOG.warn( "Exporting derivation by union is not implemented. Occured for complex element " + complex.getName() ); break; XSParticle particle = complex.getParticle(); if ( particle != null ) { exportTerm( writer, particle.getTerm(), particle.getMinOccurs(), particle.getMaxOccurs(),
List<PropertyDeclaration> getProperties( XSElementDeclaration elementDecl ) { List<PropertyDeclaration> properties = new ArrayList<PropertyDeclaration>(); XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) elementDecl.getTypeDefinition(); switch ( complexType.getContentType() ) { case XSComplexTypeDefinition.CONTENTTYPE_MIXED: case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: { XSParticle particle = complexType.getParticle(); collectProperties( particle, properties ); break; } case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: { break; } default: { // cannot happen } } return properties; }
private boolean isGroupTypeWithMultipleOccurs(XSTypeDefinition type) { return type instanceof XSComplexTypeDefinition && isGroupTypeWithMultipleOccurs(((XSComplexTypeDefinition) type).getParticle()); }
if (complexType.getAbstract()) { List<XSComplexTypeDefinition> subTypes = getSubTypes(xsModel, complexType); if (!subTypes.isEmpty()) { XSElementDeclaration elem1 = (XSElementDeclaration) item.getParent().getData(); XSComplexTypeDefinition elemType = (XSComplexTypeDefinition) elem1.getTypeDefinition(); if (elemType.getAbstract()) { doc.addAttribute(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type", doc.toQName(complexType.getNamespace(), complexType.getName())); for (int i = 0; i < complexType.getAttributeUses().getLength(); i++) { stack.push(new StackItem(complexType.getAttributeUses().get(i), item)); if (complexType.getAttributeWildcard() != null) { stack.push(new StackItem(complexType.getAttributeWildcard(), item)); if (complexType.getParticle() != null) { stack.push(new StackItem(complexType.getParticle(), item));
public static boolean checkEnumType(XSTypeDefinition td) { final XSSimpleTypeDefinition st; if (td.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { XSComplexTypeDefinition ctd = (XSComplexTypeDefinition) td; if (ctd.getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { return false; } if (ctd.getAttributeUses() != null) { for (int i = 0; i < ctd.getAttributeUses().getLength(); i++) { XSSimpleTypeDefinition xsstd = ((XSAttributeUse) ctd.getAttributeUses() .item(i)).getAttrDeclaration() .getTypeDefinition(); if ("ID".equals(xsstd.getName())) { continue; } return false; } } st = ctd.getSimpleType(); } else if (td.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { st = (XSSimpleTypeDefinition) td; } else { return false; } return st.getLexicalEnumeration() != null && st.getLexicalEnumeration().getLength() != 0; }
private List<Schema.Field> createFields(XSComplexTypeDefinition type) { final Map<String, Schema.Field> fields = new LinkedHashMap<>(); XSObjectList attrUses = type.getAttributeUses(); for (int i = 0; i < attrUses.getLength(); i++) { XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(i); XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); boolean optional = !attrUse.getRequired(); Schema.Field field = createField(fields.values(), attrDecl, attrDecl.getTypeDefinition(), optional, false); fields.put(field.getProp(Source.SOURCE), field); } XSParticle particle = type.getParticle(); if (particle == null) return new ArrayList<>(fields.values()); XSTerm term = particle.getTerm(); if (term.getType() != XSConstants.MODEL_GROUP) throw new ConverterException("Unsupported term type " + term.getType()); XSModelGroup group = (XSModelGroup) term; createGroupFields(group, fields, false); return new ArrayList<>(fields.values()); }
XSParticle particle = type.getParticle(); XSObjectList attributeUses = type.getAttributeUses(); int attrsTotal = declareNs || declareXsiType ? nsRegistry.size() + attributeUses.getLength() + 1 : if(generatedPrefix != null) String typeNsWithGeneratedPrefix = type.getNamespace(); declareNs(attrs, generatedPrefix, typeNsWithGeneratedPrefix); declareNamespace(generatedPrefix, typeNsWithGeneratedPrefix); if(type.getSimpleType() != null) XSSimpleTypeDefinition simpleType = type.getSimpleType(); String typeName = simpleType.getName(); if(attrs == null && (SimpleTypeBindings.XS_QNAME_NAME.equals(typeName) ||
public QName getGeometryType(XSComplexTypeDefinition type) { String namespaceUri = type.getNamespace(); String localName = type.getName(); QName typeName = new QName(namespaceUri, localName); if (this.gmlConstantUtils_.isGeometryType(typeName)) { return typeName; } XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type .getBaseType(); if ((parent == type) || (parent == null)) { return null; } return getGeometryType(type); }
private PrimitiveType getPrimitiveInterpretation( ValueReference propName, XSComplexTypeDefinition complexType ) { short contentType = complexType.getContentType(); if ( contentType == CONTENTTYPE_SIMPLE ) { return new PrimitiveType( complexType.getSimpleType() ); } if ( contentType == CONTENTTYPE_MIXED ) { return new PrimitiveType( STRING ); } if ( contentType == CONTENTTYPE_ELEMENT ) { String msg = "XPath '" + propName + "' refers to a complex type with complex content."; throw new IllegalArgumentException( msg ); } String msg = "XPath '" + propName + "' refers to an empty element type."; throw new IllegalArgumentException( msg ); }
public short getContentType() { return complexTypeDefinition.getContentType(); }
private boolean allowsXLink( XSComplexTypeDefinition typeDef ) { XSObjectList xsObjectList = typeDef.getAttributeUses(); for ( int i = 0; i < xsObjectList.getLength(); i++ ) { XSAttributeDeclaration attr = ( (XSAttributeUse) xsObjectList.item( i ) ).getAttrDeclaration(); if ( "href".equals( attr.getName() ) && XLNNS.equals( attr.getNamespace() ) ) { return true; } } return false; }
public static boolean checkComplexType(XSTypeDefinition td) { if (td.getTypeCategory() != XSTypeDefinition.COMPLEX_TYPE) { return false; } XSComplexTypeDefinition ctd = (XSComplexTypeDefinition) td; if (ctd.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_ELEMENT) { return true; } if ((td instanceof XSComplexTypeDecl) && ((XSComplexTypeDecl) td).getAbstract()) { return true; } if (TEXT_ELEMENTS_ARE_COMPLEX) { return true; } if (ctd.getAttributeUses() != null) { for (int i = 0; i < ctd.getAttributeUses().getLength(); i++) { XSSimpleTypeDefinition xsstd = ((XSAttributeUse) ctd.getAttributeUses().item(i)).getAttrDeclaration() .getTypeDefinition(); if ("ID".equals(xsstd.getName())) { continue; } return true; } } return false; }
XSObjectList primaryAssertions = complexTypeDef.getAssertions(); // assertions stored in the traverser layer XSSimpleTypeDefinition simpleContentType = complexTypeDef.getSimpleType(); if (simpleContentType != null) { if (complexTypeDef.getDerivationMethod() == XSConstants.DERIVATION_RESTRICTION) { Vector baseItemTypeAsserts = XS11TypeHelper.getAssertsFromSimpleType(((XSSimpleTypeDefinition)complexTypeDef.getBaseType()).getItemType()); for (int assertIdx = 0; assertIdx < baseItemTypeAsserts.size(); assertIdx++) { complexTypeAsserts.addXSObject((XSAssert) baseItemTypeAsserts.get(assertIdx));
baseType = t.getBaseType(); if (XSComplexTypeDefinition.CONTENTTYPE_SIMPLE == t.getContentType())