/** * Retrieve a DOM tree for this one schema, independent of any included or * related schemas. * @return The DOM document. * @throws XmlSchemaSerializerException */ public Document getSchemaDocument() throws XmlSchemaSerializerException { XmlSchemaSerializer xser = new XmlSchemaSerializer(); xser.setExtReg(this.parent.getExtReg()); return xser.serializeSchema(this, false)[0]; }
private void appendElement(Document doc, Element parent, Node children, XmlSchema schema) { Element elTmp = (Element) children; Element el = createNewElement(doc, elTmp.getLocalName(), schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); NamedNodeMap attributes = el.getAttributes(); el.appendChild(t); } else if (nodeType == Node.ELEMENT_NODE) { appendElement(doc, el, n, schema);
serializedFacet = constructFacet(facetObj, doc, schema, "minExclusive"); else if (facetObj instanceof XmlSchemaMinInclusiveFacet) serializedFacet = constructFacet(facetObj, doc, schema, "minInclusive"); else if (facetObj instanceof XmlSchemaMaxExclusiveFacet) serializedFacet = constructFacet(facetObj, doc, schema, "maxExclusive"); else if (facetObj instanceof XmlSchemaMaxInclusiveFacet) serializedFacet = constructFacet(facetObj, doc, schema, "maxInclusive"); else if (facetObj instanceof XmlSchemaTotalDigitsFacet) serializedFacet = constructFacet(facetObj, doc, schema, "totalDigits"); else if (facetObj instanceof XmlSchemaFractionDigitsFacet) serializedFacet = constructFacet(facetObj, doc, schema, "fractionDigits"); else if (facetObj instanceof XmlSchemaLengthFacet) serializedFacet = constructFacet(facetObj, doc, schema, "length"); else if (facetObj instanceof XmlSchemaMinLengthFacet) serializedFacet = constructFacet(facetObj, doc, schema, "minLength"); else if (facetObj instanceof XmlSchemaMaxLengthFacet) serializedFacet = constructFacet(facetObj, doc, schema, "maxLength"); else if (facetObj instanceof XmlSchemaEnumerationFacet) serializedFacet = constructFacet(facetObj, doc, schema, "enumeration");
private Element constructFacet(XmlSchemaFacet facetObj, Document doc, XmlSchema schema, String tagName) { Element facetEl = createNewElement(doc, tagName, schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); facetEl.setAttribute("value", facetObj.value.toString()); if (facetObj.fixed) facetEl.setAttribute("fixed", "true"); if (facetObj.annotation != null) { Element annotation = serializeAnnotation(doc, facetObj.annotation, schema); facetEl.appendChild(annotation); } return facetEl; }
throws XmlSchemaSerializerException { Element list = createNewElement(doc, "list", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); String listItemType = resolveQName(listObj.itemTypeName, schema); list.setAttribute("itemType", listItemType); Element inlineSimpleEl = serializeSimpleType(doc, listObj.itemType, schema); list.appendChild(inlineSimpleEl); Element annotation = serializeAnnotation(doc, listObj.annotation, schema); list.appendChild(annotation); processExtensibilityComponents(listObj,list);
Element serializedComplexType = createNewElement(doc, "complexType", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); Element simpleContent = serializeSimpleContent(doc, (XmlSchemaSimpleContent) complexTypeObj.contentModel, schema); serializedComplexType.appendChild(simpleContent); Element complexContent = serializeComplexContent(doc, (XmlSchemaComplexContent) complexTypeObj.contentModel, schema); serializedComplexType.appendChild(complexContent); Element sequence = serializeSequence(doc, (XmlSchemaSequence) complexTypeObj.particle, schema); serializedComplexType.appendChild(sequence); } else if (complexTypeObj.particle instanceof XmlSchemaChoice) { Element choice = serializeChoice(doc, (XmlSchemaChoice) complexTypeObj.particle, schema); serializedComplexType.appendChild(choice); } else if (complexTypeObj.particle instanceof XmlSchemaAll) { Element all = serializeAll(doc, (XmlSchemaAll) complexTypeObj.particle, schema); serializedComplexType.appendChild(all); } else if (complexTypeObj.particle instanceof XmlSchemaGroupRef) { Element group = serializeGroupRef(doc, (XmlSchemaGroupRef) complexTypeObj.particle, schema); serializedComplexType.appendChild(group); block = convertString(block); serializedComplexType.setAttribute(
throws XmlSchemaSerializerException { Element importEl = createNewElement(doc, "import", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); Element annotation = serializeAnnotation(doc, importObj.annotation, schema); XmlSchemaSerializer importSeri = new XmlSchemaSerializer(); importSeri.serializeSchemaElement(importObj.schema, serializeIncluded); docs.addAll(importSeri.docs); processExtensibilityComponents(importObj,importEl);
Element serializedEl = createNewElement(doc, "element", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); String resolvedName = resolveQName(elementObj.refName, schema); serializedEl.setAttribute("ref", resolvedName); } else if (elementObj.name != null && elementObj.name.length() > 0) { block = convertString(block); serializedEl.setAttribute("block", block); finalDerivation = convertString(finalDerivation); serializedEl.setAttribute("final", finalDerivation); formDef = convertString(formDef); serializedEl.setAttribute("form", formDef); serializeMaxMinOccurs(elementObj, serializedEl); String resolvedQName = resolveQName(elementObj.substitutionGroup, schema); serializedEl.setAttribute("substitutionGroup", resolvedQName); String resolvedName = resolveQName(elementObj.schemaTypeName, schema); serializedEl.setAttribute("type", resolvedName); Element annotationEl = serializeAnnotation(doc, elementObj.annotation, schema); serializedEl.appendChild(annotationEl);
XmlSchema schema) throws XmlSchemaSerializerException { Element serializedSimpleType = createNewElement(doc, "simpleType", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); tmp = convertString(tmp); serializedSimpleType.setAttribute("final", tmp); simpleTypeObj.name); if (simpleTypeObj.annotation != null) { Element annotationEl = serializeAnnotation(doc, simpleTypeObj.annotation, schema); serializedSimpleType.appendChild(annotationEl); Element restEl = serializeSimpleTypeRestriction(doc, (XmlSchemaSimpleTypeRestriction) simpleTypeObj.content, schema); serializedSimpleType.appendChild(restEl); } else if (simpleTypeObj.content instanceof XmlSchemaSimpleTypeList) { Element listEl = serializeSimpleTypeList(doc, (XmlSchemaSimpleTypeList) simpleTypeObj.content, schema); serializedSimpleType.appendChild(listEl); } else if (simpleTypeObj.content instanceof XmlSchemaSimpleTypeUnion) { Element unionEl = serializeSimpleTypeUnion(doc, (XmlSchemaSimpleTypeUnion) simpleTypeObj.content, schema); serializedSimpleType.appendChild(unionEl); processExtensibilityComponents(simpleTypeObj,serializedSimpleType);
Element anyEl = createNewElement(doc, "any", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); if (anyObj.id != null) anyEl.setAttribute("id", anyObj.id); serializeMaxMinOccurs(anyObj, anyEl); String value = anyObj.processContent.getValue(); if (!value.equals(Constants.BlockConstants.NONE)) { String processContent = convertString(value); anyEl.setAttribute("processContents", processContent); Element annotation = serializeAnnotation(doc, anyObj.annotation, schema); anyEl.appendChild(annotation); processExtensibilityComponents(anyObj,anyEl);
XmlSchema schema) throws XmlSchemaSerializerException { Element groupRef = createNewElement(doc, "group", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); String groupRefName = resolveQName(groupRefObj.refName, schema); groupRef.setAttribute("ref", groupRefName); serializeMaxMinOccurs(groupRefObj, groupRef); serializeChoice(doc, (XmlSchemaChoice) groupRefObj.particle, schema); else if (groupRefObj.particle instanceof XmlSchemaSequence) serializeSequence(doc,(XmlSchemaSequence) groupRefObj.particle, schema); else if (groupRefObj.particle instanceof XmlSchemaAll) serializeAll(doc,(XmlSchemaAll) groupRefObj.particle, schema); else throw new XmlSchemaSerializerException("The content of group " Element annotation = serializeAnnotation(doc, groupRefObj.annotation, schema); groupRef.appendChild(annotation); processExtensibilityComponents(groupRefObj,groupRef);
Element sequence = createNewElement(doc, "sequence", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); serializeMaxMinOccurs(sequenceObj, sequence); XmlSchemaObject obj = seqColl.getItem(i); if (obj instanceof XmlSchemaElement) { Element el = serializeElement(doc, (XmlSchemaElement) obj, schema); sequence.appendChild(el); } else if (obj instanceof XmlSchemaGroupRef) { Element group = serializeGroupRef(doc, (XmlSchemaGroupRef) obj, schema); sequence.appendChild(group); } else if (obj instanceof XmlSchemaChoice) { Element choice = serializeChoice(doc, (XmlSchemaChoice) obj, schema); sequence.appendChild(choice); } else if (obj instanceof XmlSchemaSequence) { Element sequenceChild = serializeSequence(doc, (XmlSchemaSequence) obj, schema); sequence.appendChild(sequenceChild); } else if (obj instanceof XmlSchemaAny) { Element any = serializeAny(doc, (XmlSchemaAny) obj, schema); sequence.appendChild(any); processExtensibilityComponents(sequenceObj,sequence);
public Source getSource() { // try to use the the package-friendly XmlSchemaSerializer first, fall back to slower stream-based version try { XmlSchemaSerializer serializer = (XmlSchemaSerializer) BeanUtils.instantiateClass(XmlSchemaSerializer.class) ; if (collection != null) { serializer.setExtReg(collection.getExtReg()); } Document[] serializedSchemas = serializer.serializeSchema(schema, false); return new DOMSource(serializedSchemas[0]); } catch (BeanInstantiationException ex) { // ignore } catch (XmlSchemaSerializer.XmlSchemaSerializerException ex) { // ignore } ByteArrayOutputStream bos = new ByteArrayOutputStream(); schema.write(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); return new StreamSource(bis); }
XmlSchema schema) throws XmlSchemaSerializerException { Element group = createNewElement(doc, "group", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); Element annotation = serializeAnnotation(doc, groupObj.annotation, schema); group.appendChild(annotation); Element sequence = serializeSequence(doc, (XmlSchemaSequence) groupObj.particle, schema); group.appendChild(sequence); } else if (groupObj.particle instanceof XmlSchemaChoice) { Element choice = serializeChoice(doc, (XmlSchemaChoice) groupObj.particle, schema); group.appendChild(choice); } else if (groupObj.particle instanceof XmlSchemaAll) { Element all = serializeAll(doc, (XmlSchemaAll) groupObj.particle, schema); group.appendChild(all); processExtensibilityComponents(groupObj,group);
XmlSchemaSimpleContent simpleContentObj, XmlSchema schema) throws XmlSchemaSerializerException { Element simpleContent = createNewElement(doc, "simpleContent", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); Element annotation = serializeAnnotation(doc, simpleContentObj.annotation, schema); simpleContent.appendChild(annotation); content = serializeSimpleContentRestriction(doc, (XmlSchemaSimpleContentRestriction) simpleContentObj.content, schema); else if (simpleContentObj.content instanceof XmlSchemaSimpleContentExtension) content = serializeSimpleContentExtension(doc, (XmlSchemaSimpleContentExtension) simpleContentObj.content, schema); processExtensibilityComponents(simpleContentObj,simpleContent);
throws XmlSchemaSerializerException { Element complexContent = createNewElement(doc, "complexContent", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); Element annotation = serializeAnnotation(doc, complexContentObj.annotation, schema); complexContent.appendChild(annotation); XmlSchemaComplexContentRestriction) content = serializeComplexContentRestriction(doc, (XmlSchemaComplexContentRestriction) complexContentObj.content, schema); else if (complexContentObj.content instanceof XmlSchemaComplexContentExtension) content = serializeComplexContentExtension(doc, (XmlSchemaComplexContentExtension) complexContentObj.content, schema); processExtensibilityComponents(complexContentObj,complexContent);
serializedSchema = setupNamespaces(serializedSchemaDocs, schemaObj); schemaElement = serializedSchema; serializedSchema.setAttribute("attributeFormDefault", convertString(formQualified)); serializedSchema.setAttribute("elementFormDefault", convertString(formQualified)); Element annotation = serializeAnnotation(serializedSchemaDocs, schemaObj.annotation, schemaObj); serializedSchema.appendChild(annotation); String blockDefault = schemaObj.blockDefault.getValue(); if (!blockDefault.equals(Constants.BlockConstants.NONE)) { blockDefault = convertString(blockDefault); serializedSchema.setAttribute("blockDefault", blockDefault); String finalDefault = schemaObj.finalDefault.getValue(); if (!finalDefault.equals(Constants.BlockConstants.NONE)) { finalDefault = convertString(finalDefault); serializedSchema.setAttribute("finalDefault", finalDefault); serializeSchemaChild(items, serializedSchema, serializedSchemaDocs, schemaObj, serializeIncluded); processExtensibilityComponents(schemaObj,serializedSchema);
Element allEl = createNewElement(doc, "all", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); serializeMaxMinOccurs(allObj, allEl); Element annotation = serializeAnnotation(doc, allObj.annotation, schema); allEl.appendChild(annotation); XmlSchemaObject obj = itemColl.getItem(i); if (obj instanceof XmlSchemaElement) { Element el = serializeElement(doc, (XmlSchemaElement) obj, schema); allEl.appendChild(el); processExtensibilityComponents(allObj,allEl);
continue; Document document = new XmlSchemaSerializer().serializeSchema(schema, false)[0]; DOMLSInput input = new DOMLSInput(document, schema.getTargetNamespace()); resolverMap.put(schema.getTargetNamespace(), input);
XmlSchema schema) throws XmlSchemaSerializerException { Element field = createNewElement(doc, "field", schema.schema_ns_prefix, XmlSchema.SCHEMA_NS); Element annotation = serializeAnnotation(doc, fieldObj.annotation, schema); field.appendChild(annotation); processExtensibilityComponents(fieldObj,field);