当前位置: 首页>>代码示例>>Java>>正文


Java XmlUtil类代码示例

本文整理汇总了Java中com.sun.xml.internal.ws.util.xml.XmlUtil的典型用法代码示例。如果您正苦于以下问题:Java XmlUtil类的具体用法?Java XmlUtil怎么用?Java XmlUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlUtil类属于com.sun.xml.internal.ws.util.xml包,在下文中一共展示了XmlUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeTo

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
    try {
        // TODO what about in-scope namespaces
        // Not very efficient consider implementing a stream buffer
        // processor that produces a DOM node from the buffer.
        TransformerFactory tf = XmlUtil.newTransformerFactory();
        Transformer t = tf.newTransformer();
        XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
        DOMResult result = new DOMResult();
        t.transform(source, result);
        Node d = result.getNode();
        if(d.getNodeType() == Node.DOCUMENT_NODE)
            d = d.getFirstChild();
        SOAPHeader header = saaj.getSOAPHeader();
        if(header == null)
            header = saaj.getSOAPPart().getEnvelope().addHeader();
        Node node = header.getOwnerDocument().importNode(d, true);
        header.appendChild(node);
    } catch (Exception e) {
        throw new SOAPException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:StreamHeader.java

示例2: writeTo

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
        try {
            // TODO what about in-scope namespaces
            // Not very efficient consider implementing a stream buffer
            // processor that produces a DOM node from the buffer.
            Transformer t = XmlUtil.newTransformer();
            SOAPHeader header = saaj.getSOAPHeader();
            if (header == null)
                header = saaj.getSOAPPart().getEnvelope().addHeader();
// TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be
// uncommented and all lines below, except the catch block, can be removed.
//            t.transform(epr.asSource(localName), new DOMResult(header));
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos);
            epr.writeTo(localName, w);
            w.flush();
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
            fac.setNamespaceAware(true);
            Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
            Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
            header.appendChild(eprNodeToAdd);
        } catch (Exception e) {
            throw new SOAPException(e);
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:EPRHeader.java

示例3: getElementTextAsQName

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
private QName getElementTextAsQName(StreamReaderBufferProcessor xsr) throws XMLStreamException {
    String text = xsr.getElementText().trim();
    String prefix = XmlUtil.getPrefix(text);
    String name = XmlUtil.getLocalPart(text);
    if (name != null) {
        if (prefix != null) {
            String ns = xsr.getNamespaceURI(prefix);
            if (ns != null) {
                return new QName(ns, name, prefix);
            }
        } else {
            return new QName(null, name);
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:WSEndpointReference.java

示例4: create

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
/**
 * The same as
 * {@link #create(Class, boolean, Invoker, QName, QName, Container, WSBinding, SDDocumentSource, Collection, EntityResolver)}
 * except that this version takes an url of the <tt>jax-ws-catalog.xml</tt>.
 *
 * @param catalogUrl
 *      if not null, an {@link EntityResolver} is created from it and used.
 *      otherwise no resolution will be performed.
 */
public static <T> WSEndpoint<T> create(
    @NotNull Class<T> implType,
    boolean processHandlerAnnotation,
    @Nullable Invoker invoker,
    @Nullable QName serviceName,
    @Nullable QName portName,
    @Nullable Container container,
    @Nullable WSBinding binding,
    @Nullable SDDocumentSource primaryWsdl,
    @Nullable Collection<? extends SDDocumentSource> metadata,
    @Nullable URL catalogUrl) {
    return create(
        implType,processHandlerAnnotation,invoker,serviceName,portName,container,binding,primaryWsdl,metadata,
        XmlUtil.createEntityResolver(catalogUrl),false);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:WSEndpoint.java

示例5: readExternalFile

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
private boolean readExternalFile(final String fileUrl) {
    InputStream ios = null;
    XMLStreamReader reader = null;
    try {
        final URL xmlURL = new URL(fileUrl);
        ios = xmlURL.openStream();
        reader = XmlUtil.newXMLInputFactory(true).createXMLStreamReader(ios);
        while (reader.hasNext()) {
            if (reader.isStartElement() && NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) {
                readSinglePolicy(policyReader.readPolicyElement(reader, fileUrl), false);
            }
            reader.next();
        }
        return true;
    } catch (IOException ioe) {
        return false;
    } catch (XMLStreamException xmlse) {
        return false;
    } finally {
        PolicyUtils.IO.closeResource(reader);
        PolicyUtils.IO.closeResource(ios);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:PolicyWSDLParserExtension.java

示例6: createDOM

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:AbstractSchemaValidationTube.java

示例7: MexEntityResolver

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public MexEntityResolver(List<? extends Source> wsdls) throws IOException {
    Transformer transformer = XmlUtil.newTransformer();
    for (Source source : wsdls) {
        XMLStreamBufferResult xsbr = new XMLStreamBufferResult();
        try {
            transformer.transform(source, xsbr);
        } catch (TransformerException e) {
            throw new WebServiceException(e);
        }
        String systemId = source.getSystemId();

        //TODO: can we do anything if the given mex Source has no systemId?
        if(systemId != null){
            SDDocumentSource doc = SDDocumentSource.create(JAXWSUtils.getFileOrURL(systemId), xsbr.getXMLStreamBuffer());
            this.wsdls.put(systemId, doc);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:MexEntityResolver.java

示例8: parseSOAPBodyBinding

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
/**
 * Returns true if body has explicit parts declaration
 */
private static boolean parseSOAPBodyBinding(XMLStreamReader reader, Map<String, ParameterBinding> parts) {
    String partsString = reader.getAttributeValue(null, "parts");
    if (partsString != null) {
        List<String> partsList = XmlUtil.parseTokenList(partsString);
        if (partsList.isEmpty()) {
            parts.put(" ", ParameterBinding.BODY);
        } else {
            for (String part : partsList) {
                parts.put(part, ParameterBinding.BODY);
            }
        }
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:RuntimeWSDLParser.java

示例9: registerNamespaces

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public void registerNamespaces(Element e) {
    for (Iterator iter = XmlUtil.getAllAttributes(e); iter.hasNext();) {
        Attr a = (Attr) iter.next();
        if (a.getName().equals(PREFIX_XMLNS)) {
            // default namespace declaration
            _nsSupport.declarePrefix("", a.getValue());
        } else {
            String prefix = XmlUtil.getPrefix(a.getName());
            if (prefix != null && prefix.equals(PREFIX_XMLNS)) {
                String nsPrefix = XmlUtil.getLocalPart(a.getName());
                String uri = a.getValue();
                _nsSupport.declarePrefix(nsPrefix, uri);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:TWSDLParserContextImpl.java

示例10: translateQualifiedName

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public QName translateQualifiedName(Locator locator, String s) {
    if (s == null)
        return null;

    String prefix = XmlUtil.getPrefix(s);
    String uri = null;

    if (prefix == null) {
        uri = getDefaultNamespaceURI();
    } else {
        uri = getNamespaceURI(prefix);
        if (uri == null) {
            errorReceiver.error(locator, WsdlMessages.PARSING_UNKNOWN_NAMESPACE_PREFIX(prefix));
        }
    }

    return new QName(uri, XmlUtil.getLocalPart(s));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:TWSDLParserContextImpl.java

示例11: writeTo

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
    try {
        // TODO what about in-scope namespaces
        // Not very efficient consider implementing a stream buffer
        // processor that produces a DOM node from the buffer.
        TransformerFactory tf = XmlUtil.newTransformerFactory(true);
        Transformer t = tf.newTransformer();
        XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
        DOMResult result = new DOMResult();
        t.transform(source, result);
        Node d = result.getNode();
        if(d.getNodeType() == Node.DOCUMENT_NODE)
            d = d.getFirstChild();
        SOAPHeader header = saaj.getSOAPHeader();
        if(header == null)
            header = saaj.getSOAPPart().getEnvelope().addHeader();
        Node node = header.getOwnerDocument().importNode(d, true);
        header.appendChild(node);
    } catch (Exception e) {
        throw new SOAPException(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:StreamHeader.java

示例12: writeTo

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
public void writeTo(SOAPMessage saaj) throws SOAPException {
        try {
            // TODO what about in-scope namespaces
            // Not very efficient consider implementing a stream buffer
            // processor that produces a DOM node from the buffer.
            Transformer t = XmlUtil.newTransformer();
            SOAPHeader header = saaj.getSOAPHeader();
            if (header == null)
                header = saaj.getSOAPPart().getEnvelope().addHeader();
// TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be
// uncommented and all lines below, except the catch block, can be removed.
//            t.transform(epr.asSource(localName), new DOMResult(header));
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos);
            epr.writeTo(localName, w);
            w.flush();
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            DocumentBuilderFactory fac = XmlUtil.newDocumentBuilderFactory(false);
            fac.setNamespaceAware(true);
            Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
            Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
            header.appendChild(eprNodeToAdd);
        } catch (Exception e) {
            throw new SOAPException(e);
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:EPRHeader.java

示例13: create

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
/**
 * The same as
 * {@link #create(Class, boolean, Invoker, QName, QName, Container, WSBinding, SDDocumentSource, Collection, EntityResolver)}
 * except that this version takes an url of the {@code jax-ws-catalog.xml}.
 *
 * @param catalogUrl
 *      if not null, an {@link EntityResolver} is created from it and used.
 *      otherwise no resolution will be performed.
 */
public static <T> WSEndpoint<T> create(
    @NotNull Class<T> implType,
    boolean processHandlerAnnotation,
    @Nullable Invoker invoker,
    @Nullable QName serviceName,
    @Nullable QName portName,
    @Nullable Container container,
    @Nullable WSBinding binding,
    @Nullable SDDocumentSource primaryWsdl,
    @Nullable Collection<? extends SDDocumentSource> metadata,
    @Nullable URL catalogUrl) {
    return create(
        implType,processHandlerAnnotation,invoker,serviceName,portName,container,binding,primaryWsdl,metadata,
        XmlUtil.createEntityResolver(catalogUrl),false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:WSEndpoint.java

示例14: buildDocList

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
/**
 * Convert metadata sources using identity transform. So that we can
 * reuse the Source object multiple times.
 */
private List<SDDocumentSource> buildDocList() {
    List<SDDocumentSource> r = new ArrayList<>();

    if (metadata != null) {
        for (Source source : metadata) {
            try {
                XMLStreamBufferResult xsbr = XmlUtil.identityTransform(source, new XMLStreamBufferResult());
                String systemId = source.getSystemId();

                r.add(SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer()));
            } catch (TransformerException | IOException | SAXException | ParserConfigurationException te) {
                throw new ServerRtException("server.rt.err", te);
            }
        }
    }

    return r;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:EndpointImpl.java

示例15: getXMLInputFactory

import com.sun.xml.internal.ws.util.xml.XmlUtil; //导入依赖的package包/类
private static XMLInputFactory getXMLInputFactory() {
    XMLInputFactory xif = null;
    if (getProperty(XMLStreamReaderFactory.class.getName()+".woodstox")) {
        try {
            xif = (XMLInputFactory)Class.forName("com.ctc.wstx.stax.WstxInputFactory").newInstance();
        } catch (Exception e) {
            if (LOGGER.isLoggable(Level.WARNING)) {
                LOGGER.log(Level.WARNING, StreamingMessages.WOODSTOX_CANT_LOAD(CLASS_NAME_OF_WSTXINPUTFACTORY), e);
            }
        }
    }
    if (xif == null) {
         xif = XmlUtil.newXMLInputFactory(true);
    }
    xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
    xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
    xif.setProperty(XMLInputFactory.IS_COALESCING, true);

    return xif;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:21,代码来源:XMLStreamReaderFactory.java


注:本文中的com.sun.xml.internal.ws.util.xml.XmlUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。