com.sun.xml.xsom.XSModelGroupDecl Java Examples

The following examples show how to use com.sun.xml.xsom.XSModelGroupDecl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private static Collection<? extends XSDeclaration> findModelGroups(final XSComplexType complexType) {
	XSContentType contentType = complexType.getExplicitContent();
	if (contentType == null) {
		contentType = complexType.getContentType();
	}
	final XSParticle particle = contentType.asParticle();
	if (particle != null && !particle.isRepeated()) {
		final XSTerm term = particle.getTerm();
		if (term instanceof XSModelGroupDecl) {
			return Collections.singletonList((XSModelGroupDecl)term);
		} else {
			final XSModelGroup modelGroup = term.asModelGroup();
			return modelGroup != null ? findModelGroups(modelGroup) : Collections.<XSModelGroupDecl>emptyList();
		}
	} else {
		return Collections.emptyList();
	}
}
 
Example #2
Source File: SchemaSetImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<XSModelGroupDecl> iterateModelGroupDecls() {
    return new Iterators.Map<XSModelGroupDecl,XSSchema>(iterateSchema()) {
        protected Iterator<XSModelGroupDecl> apply(XSSchema u) {
            return u.iterateModelGroupDecls();
        }
    };
}
 
Example #3
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void modelGroupDecl( XSModelGroupDecl decl ) {
    println(MessageFormat.format("<group name=\"{0}\">", decl.getName()));
    indent++;

    modelGroup(decl.getModelGroup());

    indent--;
    println("</group>");
}
 
Example #4
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private static List<XSModelGroupDecl> findModelGroups(final Iterable<XSParticle> modelGroup) {
	final List<XSModelGroupDecl> elementDecls = new ArrayList<>();
	for (final XSParticle child : modelGroup) {
		if (!child.isRepeated() && (child.getTerm() instanceof XSModelGroupDecl)) {
			elementDecls.add((XSModelGroupDecl) child.getTerm());
		}
	}
	return elementDecls;
}
 
Example #5
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private List<PropertyUse> findElementDecls(final XSModelGroupDecl modelGroup) {
	final List<PropertyUse> elementDecls = new ArrayList<>();
	for (final XSParticle child : modelGroup.getModelGroup()) {
		XSTerm term = child.getTerm();
		if (term instanceof XSElementDecl) {
			elementDecls.add(new PropertyUse(term));
		} else if (term instanceof XSModelGroupDecl && ((XSModelGroupDecl)term).getName().equals(modelGroup.getName())) {
			elementDecls.addAll(findElementDecls((XSModelGroupDecl)term));
		}
	}
	return elementDecls;
}
 
Example #6
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example #7
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void modelGroupDecl(XSModelGroupDecl decl) {
    SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format(
            "Group name=\"{0}\"", new Object[]{decl.getName()}),
            decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    modelGroup(decl.getModelGroup());

    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
Example #8
Source File: SchemaWriter.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void modelGroupDecl( XSModelGroupDecl decl ) {
    println(MessageFormat.format("<group name=\"{0}\">",
        new Object[]{
            decl.getName()
        }));
    indent++;

    modelGroup(decl.getModelGroup());

    indent--;
    println("</group>");
}
 
Example #9
Source File: XSDSchemaReader.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void createGroup(XSModelGroupDecl modelGroupDecl) {
	EClass eClass = ecoreFactory.createEClass();
	eClass.setName(modelGroupDecl.getName());
	ePackage.getEClassifiers().add(eClass);
	for (XSParticle particle : modelGroupDecl.getModelGroup().getChildren()) {
		XSTerm term = particle.getTerm();
		if (term.isElementDecl()) {
			String name = term.asElementDecl().getName();
			EClassifier subClass = ePackage.getEClassifier(name);
			if (subClass != null && subClass instanceof EClass) {
				((EClass) subClass).getESuperTypes().add(eClass);
			}
		}
	}
}
 
Example #10
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void schema( XSSchema s ) {

		// QUICK HACK: don't print the built-in components
		if(s.getTargetNamespace().equals(Const.schemaNamespace))
			return;

		println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
		indent++;

		Iterator<?> itr;

		itr = s.iterateAttGroupDecls();
		while(itr.hasNext())
			attGroupDecl( (XSAttGroupDecl)itr.next() );

		itr = s.iterateAttributeDecls();
		while(itr.hasNext())
			attributeDecl( (XSAttributeDecl)itr.next() );

		itr = s.iterateComplexTypes();
		while(itr.hasNext())
			complexType( (XSComplexType)itr.next() );

		itr = s.iterateElementDecls();
		while(itr.hasNext())
			elementDecl( (XSElementDecl)itr.next() );

		itr = s.iterateModelGroupDecls();
		while(itr.hasNext())
			modelGroupDecl( (XSModelGroupDecl)itr.next() );

		itr = s.iterateSimpleTypes();
		while(itr.hasNext())
			simpleType( (XSSimpleType)itr.next() );

		indent--;
		println("</schema>");
	}
 
Example #11
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void modelGroupDecl( XSModelGroupDecl decl ) {
	println(MessageFormat.format("<group name=\"{0}\">", decl.getName()));
	indent++;

	modelGroup(decl.getModelGroup());

	indent--;
	println("</group>");
}
 
Example #12
Source File: XmlUtils.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void _valueToDocument( Value value, Element element, Document doc, XSType type ) {
	addForcedAttribute( value, element );
	if( type.isSimpleType() ) {
		element.appendChild( doc.createTextNode( value.strValue() ) );
	} else if( type.isComplexType() ) {
		String name;
		Value currValue;
		XSComplexType complexType = type.asComplexType();

		// Iterate over attributes
		Collection< ? extends XSAttributeUse > attributeUses = complexType.getAttributeUses();
		for( XSAttributeUse attrUse : attributeUses ) {
			name = attrUse.getDecl().getName();
			if( (currValue = getAttributeOrNull( value, name )) != null ) {
				element.setAttribute( name, currValue.strValue() );
			}
		}

		XSContentType contentType = complexType.getContentType();
		XSParticle particle = contentType.asParticle();
		if( contentType.asSimpleType() != null ) {
			element.appendChild( doc.createTextNode( value.strValue() ) );
		} else if( particle != null ) {
			XSTerm term = particle.getTerm();
			XSModelGroupDecl modelGroupDecl;
			XSModelGroup modelGroup = null;
			if( (modelGroupDecl = term.asModelGroupDecl()) != null ) {
				modelGroup = modelGroupDecl.getModelGroup();
			} else if( term.isModelGroup() ) {
				modelGroup = term.asModelGroup();
			}
			if( modelGroup != null ) {
				_valueToDocument( value, element, doc, modelGroup );
			}
		}
	}
}
 
Example #13
Source File: XsdToJolieConverterImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private XSModelGroup getModelGroup( XSTerm term ) {
	XSModelGroupDecl modelGroupDecl;
	if( (modelGroupDecl = term.asModelGroupDecl()) != null ) {
		return modelGroupDecl.getModelGroup();
	} else if( term.isModelGroup() ) {
		return term.asModelGroup();
	} else {
		return null;
	}
}
 
Example #14
Source File: SimpleTypeVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroupDecl(XSModelGroupDecl decl) {
	todo("Model group declaration.");
}
 
Example #15
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public T modelGroupDecl(XSModelGroupDecl arg0) {
	return null;
}
 
Example #16
Source File: DefaultFunctionImpl.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public T modelGroupDecl(XSModelGroupDecl decl) {
	return defaultValue(decl);
}
 
Example #17
Source File: XsdParser.java    From jumbune with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void traverseChilds(XSTerm rfTerm) {

		if (rfTerm.isModelGroupDecl()) {

			XSModelGroupDecl rfmodelGD = rfTerm.asModelGroupDecl();

			XSModelGroup rfmodelG = rfmodelGD.getModelGroup();
			XSParticle[] rfparrs = rfmodelG.getChildren();
			for (XSParticle rfpar : rfparrs) {
				XSTerm rfsterm = rfpar.getTerm();
				if (rfsterm.isElementDecl()) {
					XSComplexType rfcomp = rfsterm.asElementDecl().getType()
							.asComplexType();
					if (rfcomp != null) {
						traverseChilds(rfsterm);
					}

				} else {
					traverseChilds(rfsterm);
				}
			}
		} else if (rfTerm.isModelGroup()) {
			XSModelGroup rmodel = rfTerm.asModelGroup();
			XSParticle[] rparrs = rmodel.getChildren();
			for (XSParticle rpar : rparrs) {
				if (rpar != null) {
					XSTerm rterm = rpar.getTerm();
					if (rterm.isElementDecl()) {
						childelements.add(rterm.asElementDecl());
						XSComplexType rcomp = rterm.asElementDecl().getType()
								.asComplexType();
						if (rcomp != null) {
							traverseChilds(rterm);
						}
					} else {
						traverseChilds(rterm);
					}

				}
			}
		} else {
			XSComplexType rtcomp = rfTerm.asElementDecl().getType()
					.asComplexType();
			XSContentType rfxscont = rtcomp.getContentType();
			XSParticle rfparticle = rfxscont.asParticle();
			if (rfparticle != null) {
				XSTerm rsterm = rfparticle.getTerm();
				traverseChilds(rsterm);
			} else {
				childelements.add(rfTerm.asElementDecl());
			}
		}
	}
 
Example #18
Source File: FindXSElementDeclVisitor.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroupDecl(XSModelGroupDecl decl) {
	decl.getModelGroup().visit(this);
}
 
Example #19
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void schema( XSSchema s) {
	
	if(this.elementsMap.size() != 0){

	StringBuffer sb = new StringBuffer();
     
     for(String prefix : uriMapping.keySet()){
    	 
    	 String uri = uriMapping.get(prefix);
    	 if(Const.schemaNamespace.equalsIgnoreCase(uri)) rootPrefix = prefix+":";
    	 sb.append("xmlns:"+prefix+"=\""+uri+"\" " );
    	 
     }
     
     if(!s.getTargetNamespace().isEmpty()){
    	 println(MessageFormat.format("<schema {0} targetNamespace=\"{1}\">",sb.toString(),s.getTargetNamespace()));
     }else{
    	 println(MessageFormat.format("<schema {0} >",sb.toString()));
     }
     
      indent++;

      Iterator<XSAttGroupDecl> itrAGD = s.iterateAttGroupDecls();
      while (itrAGD.hasNext()) {
    	  attGroupDecl(itrAGD.next());
      }

      Iterator<XSAttributeDecl> itrAD = s.iterateAttributeDecls();
      while(itrAD.hasNext()) {
    	  attributeDecl(itrAD.next());
      }

      Iterator<XSComplexType> itrCT = s.iterateComplexTypes();
      while(itrCT.hasNext()) {
    	  complexType(itrCT.next());
      }
      
      Iterator<XSElementDecl> itrED = s.iterateElementDecls();
      while(itrED.hasNext()) {
    	  elementDecl(itrED.next());
      } 
      
      Iterator<XSModelGroupDecl> itrMGD = s.iterateModelGroupDecls();
      while(itrMGD.hasNext()) {
    	  modelGroupDecl(itrMGD.next()); 
      }

      Iterator<XSSimpleType> itrST = s.iterateSimpleTypes();
      while(itrST.hasNext()) {
    	  simpleType(itrST.next());
      }

      indent--;
      println("</schema>");
	}
	//}

   
}
 
Example #20
Source File: XmlFormBuilder.java    From dynaform with Artistic License 2.0 4 votes vote down vote up
public XmlForm modelGroupDecl(XSModelGroupDecl decl) {
  if (log.isDebugEnabled())
    log.debug("Model Group Declaration: " + decl);

  return null;
}
 
Example #21
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
private List<PropertyUse> findChildDecls(final XSDeclaration groupDecl) {
	return (groupDecl instanceof XSAttGroupDecl) ? findAttributeDecls((XSAttGroupDecl) groupDecl) : findElementDecls((XSModelGroupDecl) groupDecl);
}
 
Example #22
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
private Map<QName, DefinedInterfaceOutline> generateGroupInterfaces(final Iterator<? extends XSDeclaration> groupIterator) throws SAXException {
	final Map<QName, DefinedInterfaceOutline> groupInterfaces = new HashMap<>();

	// create interface for each group
	while (groupIterator.hasNext()) {
		final XSDeclaration modelGroup = groupIterator.next();
		if (!getReferencedInterfaces().containsKey(PluginContext.getQName(modelGroup))) {
			final DefinedInterfaceOutline interfaceOutline = createInterfaceDeclaration(modelGroup);
			if (interfaceOutline != null) {
				groupInterfaces.put(interfaceOutline.getName(), interfaceOutline);
				if (this.episodeBuilder != null) {
					this.episodeBuilder.addInterface(interfaceOutline.getSchemaComponent(), interfaceOutline.getImplClass());
				}
			}
		}
	}

	// Associate interfaces with superinterfaces
	for (final DefinedInterfaceOutline typeDef : groupInterfaces.values()) {
		final XSDeclaration classComponent = typeDef.getSchemaComponent();
		final Collection<? extends XSDeclaration> groupRefs = (classComponent instanceof XSAttGroupDecl) ? ((XSAttGroupDecl) classComponent).getAttGroups() : findModelGroups(((XSModelGroupDecl) classComponent).getModelGroup());
		for (final XSDeclaration groupRef : groupRefs) {
			if (!PluginContext.getQName(groupRef).equals(typeDef.getName())) {
				InterfaceOutline superInterfaceOutline = groupInterfaces.get(PluginContext.getQName(groupRef));
				if (superInterfaceOutline == null) {
					superInterfaceOutline = getReferencedInterfaceOutline(PluginContext.getQName(groupRef));
				}
				if (superInterfaceOutline != null) {
					typeDef.addSuperInterface(superInterfaceOutline);
					typeDef.getImplClass()._implements(superInterfaceOutline.getImplClass());
					if(typeDef.getSupportInterface() != null) {
						typeDef.getSupportInterface()._implements(superInterfaceOutline.getSupportInterface());
					}
					putGroupInterfaceForClass(typeDef.getImplClass().fullName(), superInterfaceOutline);
				}
			}
		}
	}

	return groupInterfaces;
}
 
Example #23
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public QName modelGroupDecl(final XSModelGroupDecl decl) {
	return new QName(decl.getTargetNamespace(), decl.getName());
}
 
Example #24
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public QName modelGroupDecl(final XSModelGroupDecl decl) {
	return new QName(decl.getTargetNamespace(), decl.getName());
}
 
Example #25
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public Boolean modelGroupDecl(final XSModelGroupDecl decl) {
	return false;
}
 
Example #26
Source File: MultiplicityCounterNG.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Multiplicity modelGroupDecl(XSModelGroupDecl decl) {
	return modelGroup(decl.getModelGroup());
}
 
Example #27
Source File: CollectEnumerationValuesVisitor.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroupDecl(XSModelGroupDecl decl) {
	// todo("Model group declaration.");
}
 
Example #28
Source File: CollectSimpleTypeNamesVisitor.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroupDecl(XSModelGroupDecl decl) {
	// todo("Model group declaration.");
}
 
Example #29
Source File: SchemaWalker.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public void modelGroupDecl(XSModelGroupDecl decl) {
	if (shouldWalk && visited.add(decl.getModelGroup()))
		modelGroup(decl.getModelGroup());
}
 
Example #30
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Iterator<XSElementDecl> modelGroupDecl(XSModelGroupDecl decl) {
    return modelGroup(decl.getModelGroup());
}