- private void processTypeDef(final TypeDefinition<?> leafTypeDef, final JSONObject property) throws JSONException {
- if (leafTypeDef instanceof BinaryTypeDefinition) {
- processBinaryType((BinaryTypeDefinition) leafTypeDef, property);
- } else if (leafTypeDef instanceof BitsTypeDefinition) {
- processBitsType((BitsTypeDefinition) leafTypeDef, property);
- } else if (leafTypeDef instanceof EnumTypeDefinition) {
- processEnumType((EnumTypeDefinition) leafTypeDef, property);
- } else if (leafTypeDef instanceof IdentityrefTypeDefinition) {
- property.putOpt(TYPE_KEY,
- ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName());
- } else if (leafTypeDef instanceof StringTypeDefinition) {
- processStringType((StringTypeDefinition) leafTypeDef, property);
- } else if (leafTypeDef instanceof UnionTypeDefinition) {
- processUnionType((UnionTypeDefinition) leafTypeDef, property);
- } else {
- String jsonType = jsonTypeFor(leafTypeDef);
- if (jsonType == null) {
- jsonType = "object";
+ private static ObjectNode processAnyXMLNode(final AnyXmlSchemaNode leafNode) {
+ final ObjectNode property = JsonNodeFactory.instance.objectNode();
+
+ final String leafDescription = leafNode.getDescription().orElse(null);
+ putIfNonNull(property, DESCRIPTION_KEY, leafDescription);
+
+ processMandatory(leafNode, property);
+ final String localName = leafNode.getQName().getLocalName();
+ property.put(TYPE_KEY, "example of anyxml " + localName);
+
+ return property;
+ }
+
+ private String processTypeDef(final TypeDefinition<?> leafTypeDef, final DataSchemaNode node,
+ final ObjectNode property, final SchemaContext schemaContext) {
+ final String jsonType;
+ if (leafTypeDef.getDefaultValue() == null) {
+ if (leafTypeDef instanceof BinaryTypeDefinition) {
+ jsonType = processBinaryType(property);
+
+ } else if (leafTypeDef instanceof BitsTypeDefinition) {
+ jsonType = processBitsType((BitsTypeDefinition) leafTypeDef, property);
+
+ } else if (leafTypeDef instanceof EnumTypeDefinition) {
+ jsonType = processEnumType((EnumTypeDefinition) leafTypeDef, property);
+
+ } else if (leafTypeDef instanceof IdentityrefTypeDefinition) {
+ final String name = topLevelModule.getName();
+ jsonType = name + ":" + ((IdentityrefTypeDefinition) leafTypeDef).getIdentities().iterator().next()
+ .getQName().getLocalName();
+
+ } else if (leafTypeDef instanceof StringTypeDefinition) {
+ jsonType = processStringType(leafTypeDef, property, node.getQName().getLocalName());
+
+ } else if (leafTypeDef instanceof UnionTypeDefinition) {
+ jsonType = processUnionType((UnionTypeDefinition) leafTypeDef, property, schemaContext, node);
+
+ } else if (leafTypeDef instanceof EmptyTypeDefinition) {
+ jsonType = UNIQUE_EMPTY_IDENTIFIER;
+
+ } else if (leafTypeDef instanceof LeafrefTypeDefinition) {
+ return processLeafRef(node, property, schemaContext, leafTypeDef);
+
+ } else if (leafTypeDef instanceof BooleanTypeDefinition) {
+ jsonType = "true";
+
+ } else if (leafTypeDef instanceof RangeRestrictedTypeDefinition) {
+ final Number maybeLower = ((RangeRestrictedTypeDefinition<?, ?>) leafTypeDef).getRangeConstraint()
+ .map(RangeConstraint::getAllowedRanges).map(RangeSet::span).map(Range::lowerEndpoint)
+ .orElse(null);
+ jsonType = String.valueOf(maybeLower);
+
+ } else {
+ jsonType = OBJECT_TYPE;
+