Class XmlSchemaSerializer

java.lang.Object
org.apache.ws.commons.schema.XmlSchemaSerializer

public class XmlSchemaSerializer extends Object
Convert from the XML Schema class representation to the standard XML representation.
  • Field Details

  • Constructor Details

    • XmlSchemaSerializer

      public XmlSchemaSerializer()
      Create a new serializer.
  • Method Details

    • getParts

      private static String[] getParts(String name)
    • getExtReg

      public ExtensionRegistry getExtReg()
      Get the registry of extensions for this serializer.
      Returns:
      the registry.
    • serializeSchema

      public Document[] serializeSchema(XmlSchema schemaObj, boolean serializeIncluded) throws XmlSchemaSerializer.XmlSchemaSerializerException
      Serialize an entire schema, returning an array of DOM Documents, one per XSL file. If serializeIncluded is false, this will always return a single DOM document. If it is true, and there are external elements in this schema (include, import, or redefine), and they contain references to XmlSchema objects to represent them, they will be returned as additional documents in the array.
      Parameters:
      schemaObj - The XML Schema.
      serializeIncluded - whether to create DOM trees for any included or imported schemas.
      Returns:
      Documents. If serializeIncluded is false, the array with have one entry. The main document is always first.
      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • setExtReg

      public void setExtReg(ExtensionRegistry extReg)
      Set the registry of extensions for this serializer.
      Parameters:
      extReg - the registry.
    • serializeAll

      Serialize an 'all' item.
      Parameters:
      doc -
      allObj -
      schema -
      Returns:
      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeAnnotation

      Element serializeAnnotation(Document doc, XmlSchemaAnnotation annotationObj, XmlSchema schema)
      ********************************************************************* Element serializeAnnotation(Document doc, XmlSchemaAnnotation annotationObj, XmlSchema schema)

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. annotationObj - XmlSchemaAnnotation that will be serialized. schema - Schema Document object of the parent.

      Return: annotation element that part of any type. will contain document and appinfo for child. **********************************************************************

    • serializeAny

      Element serializeAny(Document doc, XmlSchemaAny anyObj, XmlSchema schema)
      ********************************************************************* Element serializeAny(Document doc, XmlSchemaAny anyObj, XmlSchema schema)

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. anyObj - XmlSchemaAny that will be serialized. schema - Schema Document object of the parent.

      Return: Element of any that is part of its parent. **********************************************************************

    • serializeAnyAttribute

      Element serializeAnyAttribute(Document doc, XmlSchemaAnyAttribute anyAttributeObj, XmlSchema schema)
      ********************************************************************* Element serializeAnyAttribute(Document doc, XmlSchemaAnyAttribute anyAttributeObj, XmlSchema schema)

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. anyAttributeObj - XmlSchemaAnyAttribute that will be serialized. schema - Schema Document object of the parent.

      Return: Element of any attribute element. **********************************************************************

    • serializeAppInfo

      Element serializeAppInfo(Document doc, XmlSchemaAppInfo appInfoObj, XmlSchema schema)
      ********************************************************************* Element serializeAppInfo(Document doc,XmlSchemaAppInfo appInfoObj, XmlSchema schema)

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. appInfoObj - XmlSchemaAppInfo that will be serialized. schema - Schema Document object of the parent.

      Return: App info element that is part of the annotation. **********************************************************************

    • serializeAttribute

      Element serializeAttribute(Document doc, XmlSchemaAttribute attributeObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeAttribute(Document doc, XmlSchemaAttribute attributeObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. `Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. attributeObj - XmlSchemaAttribute that will be serialized. schema - Schema Document object of the parent.

      Return: Element of attribute. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeAttributeGroup

      Element serializeAttributeGroup(Document doc, XmlSchemaAttributeGroup attributeGroupObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeAttributeGroup(Document doc, XmlSchemaAttributeGroup attributeGroupObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. attributeGroupObj - XmlSchemaAttributeGroup that will be serialized. schema - Schema Document object of the parent.

      Return: Element of attribute group. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeAttributeGroupRef

      Element serializeAttributeGroupRef(Document doc, XmlSchemaAttributeGroupRef attributeGroupObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeAttributeGroupRef(Document doc, XmlSchemaAttributeGroupRef attributeGroupObj, XmlSchema schema) throws XmlSchemaSerializerException

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. attributeGroupObj - XmlSchemaAttributeGroupRef that will be serialized. schema - Schema Document object of the parent.

      Return: Element of attribute group ref that part of type. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeChoice

      ********************************************************************* Element serializeChoice(Document doc, XmlSchemaChoice choiceObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. choiceObj - XmlSchemaChoice that will be serialized. schema - Schema Document object of the parent.

      Return: Element of choice schema object. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeComplexContent

      Element serializeComplexContent(Document doc, XmlSchemaComplexContent complexContentObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeComplexContent(Document doc, XmlSchemaComplexContent complexContentObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. complexContentObj - XmlSchemaComplexContent that will be serialized. schema - Schema Document object of the parent.

      Return: Element of complex type complex content. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeComplexContentExtension

      Element serializeComplexContentExtension(Document doc, XmlSchemaComplexContentExtension extensionObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeComplexContentExtension(Document doc, XmlSchemaComplexContentExtension extensionObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. extensionObj - XmlSchemaComplexContentRestriction that will be serialized. schema - Schema Document object of the parent.

      Return: Element of complex content extension. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeComplexContentRestriction

      Element serializeComplexContentRestriction(Document doc, XmlSchemaComplexContentRestriction restrictionObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeComplexContentRestriction(Document doc, XmlSchemaComplexContentRestriction restrictionObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. restrictionObj - XmlSchemaSimpleContentRestriction that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple content restriction. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeComplexType

      Element serializeComplexType(Document doc, XmlSchemaComplexType complexTypeObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeComplexType(Document doc, XmlSchemaComplexType complexTypeObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. complexTypeObj - XmlSchemaFacet that will be serialized. schema - Schema Document object of the parent.

      Return: Element of complexType. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeDocumentation

      Element serializeDocumentation(Document doc, XmlSchemaDocumentation documentationObj, XmlSchema schema)
      ********************************************************************* Element serializeDocumentation(Document doc,XmlSchemaDocumentation documentationObj, XmlSchema schema){

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. documentationObj - XmlSchemaAppInfo that will be serialized. schema - Schema Document object of the parent.

      Return: Element representation of documentation that is part of annotation. **********************************************************************

    • serializeElement

      ********************************************************************* Element serializeElement(Document doc, XmlSchemaElement elementObj, XmlSchema schema) throws XmlSchemaSerializerException

      Each member of Element will be appended and pass the element created. Element processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. elementObj - XmlSchemaInclude that will be serialized. schema - Schema Document object of the parent.

      Return: Element object of element. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeFacet

      ********************************************************************* Element serializeFacet(Document doc, XmlSchemaFacet facetObj, XmlSchema schema) throws XmlSchemaSerializerException{

      detect what type of facet and cass appropriatelly, construct the element and pass it.

      Parameter: doc - Document the parent use. facetObj - XmlSchemaFacet that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple type with facet. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeField

      ********************************************************************* Element serializeField(Document doc, XmlSchemaXPath fieldObj, XmlSchema schema) throws XmlSchemaSerializerException

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. fieldObj - XmlSchemaXPath that will be serialized. schema - Schema Document object of the parent.

      Return: field element that part of constraint. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeGroup

      ********************************************************************* Element serializeGroup(Document doc, XmlSchemaGroup groupObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. groupObj - XmlSchemaGroup that will be serialized. schema - Schema Document object of the parent.

      Return: Element of group elements. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeGroupRef

      ********************************************************************* Element serializeGroupRef(Document doc, XmlSchemaGroupRef groupRefObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. groupRefObj - XmlSchemaGroupRef that will be serialized. schema - Schema Document object of the parent.

      Return: Element of group elements ref inside its parent. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeIdentityConstraint

      Element serializeIdentityConstraint(Document doc, XmlSchemaIdentityConstraint constraintObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeIdentityConstraint(Document doc, XmlSchemaIdentityConstraint constraintObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. constraintObj - XmlSchemaIdentityConstraint that will be serialized. schema - Schema Document object of the parent.

      Return: Element of key, keyref or unique that part of its parent. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeImport

      Element serializeImport(Document doc, XmlSchemaImport importObj, XmlSchema schema, boolean serializeIncluded) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeImport(Document doc, XmlSchemaImport importObj, XmlSchema schema)throws XmlSchemaSerializerException

      Add each of the attribute of XmlSchemaImport obj into import Element Then serialize schema that is included by this import. Include the serialized schema into document pool.

      Parameter: doc - Document the parent use. includeObj - XmlSchemaInclude that will be serialized. schema - Schema Document object of the parent.

      Return: Element object representation of XmlSchemaImport **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeInclude

      Element serializeInclude(Document doc, XmlSchemaInclude includeObj, XmlSchema schema, boolean serializeIncluded) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeInclude(Document doc, XmlSchemaInclude includeObj, XmlSchema schema)throws XmlSchemaSerializerException

      set appropriate attribute as per this object attribute availability. Call included schema to append to this schema document collection. Then add the document created into document pool.

      Parameter: doc - Document the parent use. includeObj - XmlSchemaInclude that will be serialized. schema - Schema Document object of the parent.

      Return: Element object representation of XmlSchemaInclude **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeRedefine

      ********************************************************************* Element serializeRedefine(Document doc, XmlSchemaRedefine redefineObj, XmlSchema schema)throws XmlSchemaSerializerException

      Add each of the attribute of XmlSchemaImport obj into import Element Then serialize schema that is included by this import. Include the serialized schema into document pool.

      Parameter: doc - Document the parent use. redefineObj - XmlSchemaInclude that will be serialized. schema - Schema Document object of the parent.

      Return: Element object representation of XmlSchemaRedefine **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSchemaElement

      Document[] serializeSchemaElement(XmlSchema schemaObj, boolean serializeIncluded) throws XmlSchemaSerializer.XmlSchemaSerializerException
      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSelector

      Element serializeSelector(Document doc, XmlSchemaXPath selectorObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeSelector(Document doc, XmlSchemaXPath selectorObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. selectorObj - XmlSchemaXPath that will be serialized. schema - Schema Document object of the parent.

      Return: Element of selector with collection of xpath as its attrib. The selector itself is the part of identity type. eg invalid input: '<'selector xpath="..." **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSequence

      ********************************************************************* Element serializeSequence(Document doc, XmlSchemaSequence sequenceObj, XmlSchema schema)throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. `Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. sequenceObj - XmlSchemaFacet that will be serialized. schema - Schema Document object of the parent.

      Return: Element of sequence particle. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleContent

      Element serializeSimpleContent(Document doc, XmlSchemaSimpleContent simpleContentObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeSimpleContent(Document doc, XmlSchemaSimpleContent simpleContentObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. simpleContentObj - XmlSchemaSimpleContent that will be serialized. schema - Schema Document object of the parent.

      Return: Element of complex type simple content. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleContentExtension

      Element serializeSimpleContentExtension(Document doc, XmlSchemaSimpleContentExtension extensionObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeSimpleContentExtension(Document doc, XmlSchemaSimpleContentExtension extensionObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. extensionObj - XmlSchemaSimpleContentExtension that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple content extension. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleContentRestriction

      Element serializeSimpleContentRestriction(Document doc, XmlSchemaSimpleContentRestriction restrictionObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeSimpleContentRestriction(Document doc, XmlSchemaSimpleContentRestriction restrictionObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. restrictionObj - XmlSchemaSimpleContentRestriction that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple content restriction. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleType

      Element serializeSimpleType(Document doc, XmlSchemaSimpleType simpleTypeObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeSimpleType(Document doc, XmlSchemaSimpleType simpleTypeObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of simple type will be appended and pass the element created. Simple type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. simpleTypeObj - XmlSchemaSimpleType that will be serialized. schema - Schema Document object of the parent.

      Return: Element object of SimpleType **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleTypeList

      ********************************************************************* Element serializeSimpleTypeList(Document doc, XmlSchemaSimpleTypeList listObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. listObj - XmlSchemaSimpleTypeList that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple type with list method. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleTypeRestriction

      Element serializeSimpleTypeRestriction(Document doc, XmlSchemaSimpleTypeRestriction restrictionObj, XmlSchema schema) throws XmlSchemaSerializer.XmlSchemaSerializerException
      ********************************************************************* Element serializeSimpleTypeRestriction(Document doc, XmlSchemaSimpleTypeRestriction restrictionObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of simple type will be appended and pass the element created. Simple type's processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. restrictionObj - XmlSchemaRestriction that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple type restriction and its child. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • serializeSimpleTypeUnion

      ********************************************************************* Element serializeSimpleTypeUnion(Document doc, XmlSchemaSimpleTypeUnion unionObj, XmlSchema schema) throws XmlSchemaSerializerException{

      Each member of complex type will be appended and pass the element created. Complex type processed according to w3c Recommendation May 2 2001.

      Parameter: doc - Document the parent use. unionObj - XmlSchemaSimpleTypeUnion that will be serialized. schema - Schema Document object of the parent.

      Return: Element of simple type with union method. **********************************************************************

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • setupAttr

      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • appendElement

      private void appendElement(Document doc, Element parent, Node children, XmlSchema schema)
    • constructFacet

      private Element constructFacet(XmlSchemaFacet facetObj, Document doc, XmlSchema schema, String tagName)
    • createNewElement

      private Element createNewElement(Document document, String localName, String prefix, String namespace)
    • processExtensibilityComponents

      private void processExtensibilityComponents(XmlSchemaObject schemaObject, Element parentElement)
      A generic method to process the extra attributes and the extra elements present within the schema. What are considered extensions are child elements with non schema namespace and child attributes with any namespace.
      Parameters:
      schemaObject -
      parentElement -
    • resolveQName

      private String resolveQName(QName names, XmlSchema schemaObj)
      will search whether the prefix is available in global hash table, if it is there than append the prefix to the element name. If not then it will create new prefix corresponding to that namespace and store that in hash table. Finally add the new prefix and namespace to element
      Parameters:
      names -
      schemaObj -
      Returns:
      resolved QName of the string
    • serializeMaxMinOccurs

      private void serializeMaxMinOccurs(XmlSchemaParticle particle, Element element)
      A common method to serialize the max/min occurs
      Parameters:
      particle -
      element -
    • serializeSchemaChild

      private void serializeSchemaChild(List<XmlSchemaObject> items, Element serializedSchema, Document serializedSchemaDocs, XmlSchema schemaObj, boolean serializeIncluded) throws XmlSchemaSerializer.XmlSchemaSerializerException
      Throws:
      XmlSchemaSerializer.XmlSchemaSerializerException
    • setupNamespaces

      private Element setupNamespaces(Document schemaDocs, XmlSchema schemaObj)
      Set up namespaces appropriately and append that attr into specified element