
org.ow2.easywsdl.tooling.xsd2xml.XSD2XML Maven / Gradle / Ivy
/**
* Copyright (c) 2008-2012 EBM WebSourcing, 2012-2016 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the New BSD License (3-clause license).
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the New BSD License (3-clause license)
* for more details.
*
* You should have received a copy of the New BSD License (3-clause license)
* along with this program/library; If not, see http://directory.fsf.org/wiki/License:BSD_3Clause/
* for the New BSD License (3-clause license).
*/
package org.ow2.easywsdl.tooling.xsd2xml;
import java.util.HashMap;
import java.util.Map;
import org.jdom.output.Format;
import org.ow2.easywsdl.schema.DefaultSchemaImpl;
import org.ow2.easywsdl.schema.SchemaFactory;
import org.ow2.easywsdl.schema.api.SchemaException;
import org.ow2.easywsdl.schema.api.Type;
import org.ow2.easywsdl.schema.api.absItf.AbsItfElement;
import org.ow2.easywsdl.schema.org.w3._2001.xmlschema.FormChoice;
/**
* @author Nicolas Salatge - EBM WebSourcing
*/
public abstract class XSD2XML {
public static XSD2XML newInstance() {
return new XSD2XMLImpl();
}
public abstract String printXml(final AbsItfElement e, Object value) throws SchemaException;
/**
* Prints an element once it has been generated with this class.
*
* Equivalent to {@link #printXml(org.jdom.Element, Format)} with an
* already defined formatter.
*
*
* @param element the element to use as generation input
* @return a String representation of a XML request matching the given element
* @see #printXml(org.jdom.Element, Format)
*/
public abstract String printXml( org.jdom.Element element );
/**
* Prints an element once it has been generated with this class.
*
* This method avoids to redeclare name spaces that have already been defined in a parent element.
*
*
* @param element the element to use as generation input
* @param formatter a custom JDOM formatter
* @return a String representation of a XML request matching the given element
*/
public abstract String printXml( org.jdom.Element element, Format formatter );
public abstract String printXml(final AbsItfElement e, Map value, boolean createOptionalElement, boolean createOptionalAttribute) throws SchemaException;
public abstract org.jdom.Element generateElement(final AbsItfElement eIn, final Object values) throws SchemaException;
public abstract org.jdom.Element generateElement(AbsItfElement eIn, Map values, FormChoice form, int minOccurs, boolean createOptionalElement, boolean createOptionalAttribute)
throws SchemaException;
public abstract org.jdom.Element addMinOccursEqual0OrArrayElement(final AbsItfElement childDefinition, final org.jdom.Element parentElement) throws SchemaException;
public static Map createDefaultMap(Object value) {
Map values = new HashMap();
for(Type type: SchemaFactory.getDefaultSchema().getTypes()) {
values.put(type, value);
}
return values;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy