Java Code Examples for org.apache.xerces.xs.XSComplexTypeDefinition#getName()

The following examples show how to use org.apache.xerces.xs.XSComplexTypeDefinition#getName() . 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: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 6 votes vote down vote up
private void handleComplexTypeDefinitionOfElementContentType(XSComplexTypeDefinition complexTypeDefinition, boolean shouldCreateReferences, JsonObjectBuilder builder){
	if(shouldCreateReferences){
		String complexTypeDefinitionName = complexTypeDefinition.getName();

		if(complexTypeDefinitionName == null && complexTypeDefinition.getContext() != null  && complexTypeDefinition.getContext().getNamespaceItem() != null){
			complexTypeDefinitionName = complexTypeDefinition.getContext().getName(); // complex type definition name defaults to name of context
		}

		if(complexTypeDefinitionName != null){
			if (log.isTraceEnabled()) log.trace("handleComplexTypeDefinitionOfElementContentType creating ref!");

			builder.add("$ref", definitionsPath+complexTypeDefinitionName);
			return;
		}
	}
	
	XSObjectList attributeUses = complexTypeDefinition.getAttributeUses();

	XSParticle particle = complexTypeDefinition.getParticle();
	handleParticle(builder, particle, attributeUses, false);
}
 
Example 2
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 6 votes vote down vote up
private void handleComplexTypeDefinitionOfSimpleContentType(XSComplexTypeDefinition complexTypeDefinition, boolean shouldCreateReferences, JsonObjectBuilder builder){
	if(shouldCreateReferences){
		String complexTypeDefinitionName = complexTypeDefinition.getName();

		if(complexTypeDefinitionName == null && complexTypeDefinition.getContext() != null  && complexTypeDefinition.getContext().getNamespaceItem() != null){
			complexTypeDefinitionName = complexTypeDefinition.getContext().getName(); // complex type definition name defaults to name of context
		}

		if(complexTypeDefinitionName != null){
			if (!(complexTypeDefinitionName.equals("anyType") && complexTypeDefinition.getNamespace().endsWith(XML_SCHEMA_NS))) {
				if (log.isTraceEnabled()) log.trace("handleComplexTypeDefinitionOfElementContentType creating ref!");
				builder.add("$ref", definitionsPath+complexTypeDefinitionName);
			}
			
			return;
		}
	}
	
	XSObjectList attributeUses = complexTypeDefinition.getAttributeUses();
	
	buildObject(builder, null, attributeUses, mixedContentLabel, complexTypeDefinition.getBaseType());
}