Search in sources :

Example 1 with XmlSerializer

use of com.sun.xml.txw2.output.XmlSerializer in project metro-jax-ws by eclipse-ee4j.

the class WSDLGenerator method doGeneration.

/**
 * Performes the actual WSDL generation
 */
public void doGeneration() {
    XmlSerializer serviceWriter;
    XmlSerializer portWriter = null;
    String fileName = mangleName(model.getServiceQName().getLocalPart());
    Result result = wsdlResolver.getWSDL(fileName + DOT_WSDL);
    wsdlLocation = result.getSystemId();
    serviceWriter = new CommentFilter(ResultFactory.createSerializer(result));
    if (model.getServiceQName().getNamespaceURI().equals(model.getTargetNamespace())) {
        portWriter = serviceWriter;
        schemaPrefix = fileName + "_";
    } else {
        String wsdlName = mangleName(model.getPortTypeName().getLocalPart());
        if (wsdlName.equals(fileName))
            wsdlName += "PortType";
        Holder<String> absWSDLName = new Holder<>();
        absWSDLName.value = wsdlName + DOT_WSDL;
        result = wsdlResolver.getAbstractWSDL(absWSDLName);
        if (result != null) {
            portWSDLID = result.getSystemId();
            if (portWSDLID.equals(wsdlLocation)) {
                portWriter = serviceWriter;
            } else {
                portWriter = new CommentFilter(ResultFactory.createSerializer(result));
            }
        } else {
            portWSDLID = absWSDLName.value;
        }
        schemaPrefix = new java.io.File(portWSDLID).getName();
        int idx = schemaPrefix.lastIndexOf('.');
        if (idx > 0)
            schemaPrefix = schemaPrefix.substring(0, idx);
        schemaPrefix = mangleName(schemaPrefix) + "_";
    }
    generateDocument(serviceWriter, portWriter);
}
Also used : Holder(jakarta.xml.ws.Holder) XmlSerializer(com.sun.xml.txw2.output.XmlSerializer) Result(javax.xml.transform.Result) SAXResult(javax.xml.transform.sax.SAXResult) TXWResult(com.sun.xml.txw2.output.TXWResult) DOMResult(javax.xml.transform.dom.DOMResult)

Example 2 with XmlSerializer

use of com.sun.xml.txw2.output.XmlSerializer in project jaxb-ri by eclipse-ee4j.

the class TXW method create.

/**
 * Creates a new {@link TypedXmlWriter} to write a new instance of a document.
 *
 * @param <T> an instance of {@link TypedXmlWriter}
 * @param rootElement
 *      The {@link TypedXmlWriter} interface that declares the content model of the root element.
 *      This interface must have {@link XmlElement} annotation on it to designate the tag name
 *      of the root element.
 * @param out
 *      The target of the writing.
 * @return
 *      always return non-null {@link TypedXmlWriter} that can be used
 *      to write the contents of the root element.
 */
public static <T extends TypedXmlWriter> T create(Class<T> rootElement, XmlSerializer out) {
    if (out instanceof TXWSerializer) {
        TXWSerializer txws = (TXWSerializer) out;
        return txws.txw._element(rootElement);
    }
    Document doc = new Document(out);
    QName n = getTagName(rootElement);
    return new ContainerElement(doc, null, n.getNamespaceURI(), n.getLocalPart())._cast(rootElement);
}
Also used : TXWSerializer(com.sun.xml.txw2.output.TXWSerializer) QName(javax.xml.namespace.QName)

Aggregations

TXWResult (com.sun.xml.txw2.output.TXWResult)1 TXWSerializer (com.sun.xml.txw2.output.TXWSerializer)1 XmlSerializer (com.sun.xml.txw2.output.XmlSerializer)1 Holder (jakarta.xml.ws.Holder)1 QName (javax.xml.namespace.QName)1 Result (javax.xml.transform.Result)1 DOMResult (javax.xml.transform.dom.DOMResult)1 SAXResult (javax.xml.transform.sax.SAXResult)1