Java Code Examples for org.apache.xerces.xs.XSComplexTypeDefinition#CONTENTTYPE_EMPTY
The following examples show how to use
org.apache.xerces.xs.XSComplexTypeDefinition#CONTENTTYPE_EMPTY .
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: CMXSDElementDeclaration.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isEmpty() { XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition(); if (typeDefinition != null && typeDefinition.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { XSComplexTypeDefinition complexTypeDefinition = (XSComplexTypeDefinition) typeDefinition; return complexTypeDefinition.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_EMPTY; } return false; }
Example 2
Source File: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 5 votes |
public JsonObject getDefinition(XSTypeDefinition typeDefinition, boolean shouldCreateReferences) { JsonObjectBuilder builder = Json.createObjectBuilder(); switch (typeDefinition.getTypeCategory()) { case XSTypeDefinition.COMPLEX_TYPE: XSComplexTypeDefinition complexTypeDefinition = (XSComplexTypeDefinition)typeDefinition; switch (complexTypeDefinition.getContentType()) { case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: if (log.isTraceEnabled()) log.trace("getDefinition complexTypeDefinition.contentType is Empty, no child elements"); break; case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: if (log.isTraceEnabled()) log.trace("getDefinition complexTypeDefinition.contentType is Simple, no child elements (only characters)"); handleComplexTypeDefinitionOfSimpleContentType(complexTypeDefinition, shouldCreateReferences, builder); break; case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: if (log.isTraceEnabled()) log.trace("getDefinition complexTypeDefinition.contentType is Element, complexTypeDefinition ["+ToStringBuilder.reflectionToString(complexTypeDefinition,ToStringStyle.MULTI_LINE_STYLE)+"]"); handleComplexTypeDefinitionOfElementContentType(complexTypeDefinition, shouldCreateReferences, builder); break; case XSComplexTypeDefinition.CONTENTTYPE_MIXED: if (log.isTraceEnabled()) log.trace("getDefinition complexTypeDefinition.contentType is Mixed"); handleComplexTypeDefinitionOfSimpleContentType(complexTypeDefinition, shouldCreateReferences, builder); break; default: throw new IllegalStateException("getDefinition complexTypeDefinition.contentType is not Empty,Simple,Element or Mixed, but ["+complexTypeDefinition.getContentType()+"]"); } if (log.isTraceEnabled()) log.trace(ToStringBuilder.reflectionToString(complexTypeDefinition,ToStringStyle.MULTI_LINE_STYLE)); break; case XSTypeDefinition.SIMPLE_TYPE: handleSimpleTypeDefinition(typeDefinition, builder); break; default: throw new IllegalStateException("getDefinition typeDefinition.typeCategory is not Complex or Simple, but ["+typeDefinition.getTypeCategory()+"]"); } return builder.build(); }
Example 3
Source File: JsonElementContainer.java From iaf with Apache License 2.0 | 5 votes |
public JsonElementContainer(String name, boolean xmlArrayContainer, boolean repeatedElement, boolean skipArrayElementContainers, String attributePrefix, String mixedContentLabel, XSTypeDefinition typeDefinition) { this.name=name; this.xmlArrayContainer=xmlArrayContainer; this.repeatedElement=repeatedElement; this.skipArrayElementContainers=skipArrayElementContainers; this.attributePrefix=attributePrefix; this.mixedContentLabel=mixedContentLabel; if (typeDefinition!=null) { switch(typeDefinition.getTypeCategory()) { case XSTypeDefinition.SIMPLE_TYPE: setType(ScalarType.findType(((XSSimpleType)typeDefinition))); break; case XSTypeDefinition.COMPLEX_TYPE: XSComplexTypeDefinition complexTypeDefinition=(XSComplexTypeDefinition)typeDefinition; switch (complexTypeDefinition.getContentType()) { case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: if (log.isTraceEnabled()) log.trace("JsonElementContainer complexTypeDefinition.contentType is Empty, no child elements"); break; case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: if (log.isTraceEnabled()) log.trace("JsonElementContainer complexTypeDefinition.contentType is Simple, no child elements (only characters)"); setType(ScalarType.findType((XSSimpleType)complexTypeDefinition.getBaseType())); break; case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: if (log.isTraceEnabled()) log.trace("JsonElementContainer complexTypeDefinition.contentType is Element"); break; case XSComplexTypeDefinition.CONTENTTYPE_MIXED: if (log.isTraceEnabled()) log.trace("JsonElementContainer complexTypeDefinition.contentType is Mixed"); break; } } } }
Example 4
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
public void handleElementContents(XSElementDeclaration elementDeclaration, N node) throws SAXException { XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition(); if (typeDefinition==null) { log.warn("handleElementContents typeDefinition is null"); handleSimpleTypedElement(elementDeclaration, null, node); return; } switch (typeDefinition.getTypeCategory()) { case XSTypeDefinition.SIMPLE_TYPE: if (log.isTraceEnabled()) log.trace("handleElementContents typeDefinition.typeCategory is SimpleType, no child elements"); handleSimpleTypedElement(elementDeclaration, (XSSimpleTypeDefinition)typeDefinition, node); return; case XSTypeDefinition.COMPLEX_TYPE: XSComplexTypeDefinition complexTypeDefinition=(XSComplexTypeDefinition)typeDefinition; switch (complexTypeDefinition.getContentType()) { case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: if (log.isTraceEnabled()) log.trace("handleElementContents complexTypeDefinition.contentType is Empty, no child elements"); return; case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: if (log.isTraceEnabled()) log.trace("handleElementContents complexTypeDefinition.contentType is Simple, no child elements (only characters)"); handleSimpleTypedElement(elementDeclaration, null, node); return; case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: case XSComplexTypeDefinition.CONTENTTYPE_MIXED: handleComplexTypedElement(elementDeclaration,node); return; default: throw new IllegalStateException("handleElementContents complexTypeDefinition.contentType is not Empty,Simple,Element or Mixed, but ["+complexTypeDefinition.getContentType()+"]"); } default: throw new IllegalStateException("handleElementContents typeDefinition.typeCategory is not SimpleType or ComplexType, but ["+typeDefinition.getTypeCategory()+"] class ["+typeDefinition.getClass().getName()+"]"); } }
Example 5
Source File: ToXml.java From iaf with Apache License 2.0 | 4 votes |
public List<XSParticle> getBestChildElementPath(XSElementDeclaration elementDeclaration, N node, boolean silent) throws SAXException { XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition(); if (typeDefinition==null) { log.warn("getBestChildElementPath typeDefinition is null"); return null; } switch (typeDefinition.getTypeCategory()) { case XSTypeDefinition.SIMPLE_TYPE: if (log.isTraceEnabled()) log.trace("getBestChildElementPath typeDefinition.typeCategory is SimpleType, no child elements"); return null; case XSTypeDefinition.COMPLEX_TYPE: XSComplexTypeDefinition complexTypeDefinition=(XSComplexTypeDefinition)typeDefinition; switch (complexTypeDefinition.getContentType()) { case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: if (log.isTraceEnabled()) log.trace("getBestChildElementPath complexTypeDefinition.contentType is Empty, no child elements"); return null; case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: if (log.isTraceEnabled()) log.trace("getBestChildElementPath complexTypeDefinition.contentType is Simple, no child elements (only characters)"); return null; case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: case XSComplexTypeDefinition.CONTENTTYPE_MIXED: XSParticle particle = complexTypeDefinition.getParticle(); if (particle==null) { throw new IllegalStateException("getBestChildElementPath complexTypeDefinition.particle is null for Element or Mixed contentType"); // log.warn("typeDefinition particle is null, is this a problem?"); // return null; } if (log.isTraceEnabled()) log.trace("typeDefinition particle ["+ToStringBuilder.reflectionToString(particle,ToStringStyle.MULTI_LINE_STYLE)+"]"); List<XSParticle> result=new LinkedList<XSParticle>(); List<String> failureReasons=new LinkedList<String>(); if (getBestMatchingElementPath(elementDeclaration, node, particle, result, failureReasons)) { return result; } String msg="Cannot find path:"; for (String reason:failureReasons) { msg+='\n'+reason; } if (!silent) { handleError(msg); } return null; default: throw new IllegalStateException("getBestChildElementPath complexTypeDefinition.contentType is not Empty,Simple,Element or Mixed, but ["+complexTypeDefinition.getContentType()+"]"); } default: throw new IllegalStateException("getBestChildElementPath typeDefinition.typeCategory is not SimpleType or ComplexType, but ["+typeDefinition.getTypeCategory()+"] class ["+typeDefinition.getClass().getName()+"]"); } }