gpt4 book ai didi

com.sun.xml.ws.util.xml.XmlUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 19:43:05 28 4
gpt4 key购买 nike

本文整理了Java中com.sun.xml.ws.util.xml.XmlUtil类的一些代码示例,展示了XmlUtil类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtil类的具体详情如下:
包路径:com.sun.xml.ws.util.xml.XmlUtil
类名称:XmlUtil

XmlUtil介绍

暂无

代码示例

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

/**
 * Creates an {@link EntityResolver} that consults {@code /WEB-INF/jax-ws-catalog.xml}.
 */
private EntityResolver createEntityResolver() {
  try {
    return XmlUtil.createEntityResolver(loader.getCatalogFile());
  } catch (MalformedURLException e) {
    throw new WebServiceException(e);
  }
}

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

public static QName getQName(XMLStreamReader reader, String tag){
  String localName = XmlUtil.getLocalPart(tag);
  String pfix = XmlUtil.getPrefix(tag);
  String uri = reader.getNamespaceURI(fixNull(pfix));
  return new QName(uri, localName);
}

代码示例来源:origin: com.sun.xml.ws/rt

private static void displayDOM(Node node, java.io.OutputStream ostream) {
  try {
    System.out.println("\n====\n");
    XmlUtil.newTransformer().transform(
      new DOMSource(node), new StreamResult(ostream));
    System.out.println("\n====\n");
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: javaee/metro-jax-ws

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);
      }
    }
  }
}

代码示例来源:origin: com.sun.xml.ws/rt

/**
 * Performs identity transformation.
 * @param <T>
 * @param src
 * @param result
 * @return
 * @throws javax.xml.transform.TransformerException
 * @throws java.io.IOException
 * @throws org.xml.sax.SAXException
 * @throws javax.xml.parsers.ParserConfigurationException
 */
public static <T extends Result> T identityTransform(Source src, T result)
    throws TransformerException, SAXException, ParserConfigurationException, IOException {
  if (src instanceof StreamSource) {
    // work around a bug in JAXP in JDK6u4 and earlier where the namespace processing
    // is not turned on by default
    StreamSource ssrc = (StreamSource) src;
    TransformerHandler th = ((SAXTransformerFactory) transformerFactory.get()).newTransformerHandler();
    th.setResult(result);
    XMLReader reader = saxParserFactory.get().newSAXParser().getXMLReader();
    reader.setContentHandler(th);
    reader.setProperty(LEXICAL_HANDLER_PROPERTY, th);
    reader.parse(toInputSource(ssrc));
  } else {
    newTransformer().transform(src, result);
  }
  return result;
}

代码示例来源:origin: com.sun.xml.ws/rt

msEpr.addr = new MemberSubmissionEndpointReference.Address();
msEpr.addr.uri = XmlUtil.getTextForNode(child);
    String prefix = XmlUtil.getPrefix(service);
    String name = XmlUtil.getLocalPart(service);
    String prefix = XmlUtil.getPrefix(portType);
    String name = XmlUtil.getLocalPart(portType);

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

/**
 * 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;
}

代码示例来源:origin: javaee/metro-jax-ws

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);
    }
  }

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

void addSchema(Source schema) {
  assert schema.getSystemId() != null;
  String systemId = schema.getSystemId();
  try {
    XMLStreamBufferResult xsbr = XmlUtil.identityTransform(schema, new XMLStreamBufferResult());
    SDDocumentSource sds = SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer());
    SDDocument sdoc = SDDocumentImpl.create(sds, new QName(""), new QName(""));
    docs.put(systemId, sdoc);
    nsMapping.put(((SDDocument.Schema)sdoc).getTargetNamespace(), sdoc);
  } catch(Exception ex) {
    LOGGER.log(Level.WARNING, "Exception in adding schemas to resolver", ex);
  }
}

代码示例来源:origin: com.sun.xml.ws/jaxws-tools

@Override
  protected XPathFactory initialValue() throws Exception {
    return XmlUtil.newXPathFactory(true);
  }
};

代码示例来源:origin: com.sun.xml.ws/jaxws-tools

public static String getRequiredAttribute(Element element, String name) {
  String result = XmlUtil.getAttributeOrNull(element, name);
  if (result == null)
    fail(
      "parsing.missingRequiredAttribute",
      element.getTagName(),
      name);
  return result;
}

代码示例来源:origin: javaee/metro-jax-ws

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);
      }
    }
  }
}

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

msEpr.addr = new MemberSubmissionEndpointReference.Address();
msEpr.addr.uri = XmlUtil.getTextForNode(child);
    String prefix = XmlUtil.getPrefix(service);
    String name = XmlUtil.getLocalPart(service);
    String prefix = XmlUtil.getPrefix(portType);
    String name = XmlUtil.getLocalPart(portType);

代码示例来源:origin: com.sun.xml.ws/rt

/**
 * 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;
}

代码示例来源:origin: javaee/metro-jax-ws

/**
 * Performs identity transformation.
 * @param <T>
 * @param src
 * @param result
 * @return
 * @throws javax.xml.transform.TransformerException
 * @throws java.io.IOException
 * @throws org.xml.sax.SAXException
 * @throws javax.xml.parsers.ParserConfigurationException
 */
public static <T extends Result> T identityTransform(Source src, T result)
    throws TransformerException, SAXException, ParserConfigurationException, IOException {
  if (src instanceof StreamSource) {
    // work around a bug in JAXP in JDK6u4 and earlier where the namespace processing
    // is not turned on by default
    StreamSource ssrc = (StreamSource) src;
    TransformerHandler th = ((SAXTransformerFactory) transformerFactory.get()).newTransformerHandler();
    th.setResult(result);
    XMLReader reader = saxParserFactory.get().newSAXParser().getXMLReader();
    reader.setContentHandler(th);
    reader.setProperty(LEXICAL_HANDLER_PROPERTY, th);
    reader.parse(toInputSource(ssrc));
  } else {
    newTransformer().transform(src, result);
  }
  return result;
}

代码示例来源:origin: com.sun.xml.ws/jaxws-rt

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);
    }
  }

代码示例来源:origin: com.sun.xml.ws/rt

void addSchema(Source schema) {
  assert schema.getSystemId() != null;
  String systemId = schema.getSystemId();
  try {
    XMLStreamBufferResult xsbr = XmlUtil.identityTransform(schema, new XMLStreamBufferResult());
    SDDocumentSource sds = SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer());
    SDDocument sdoc = SDDocumentImpl.create(sds, new QName(""), new QName(""));
    docs.put(systemId, sdoc);
    nsMapping.put(((SDDocument.Schema)sdoc).getTargetNamespace(), sdoc);
  } catch(Exception ex) {
    LOGGER.log(Level.WARNING, "Exception in adding schemas to resolver", ex);
  }
}

代码示例来源:origin: org.glassfish.metro/webservices-tools

@Override
  protected XPathFactory initialValue() throws Exception {
    return XmlUtil.newXPathFactory(true);
  }
};

代码示例来源:origin: org.glassfish.metro/webservices-tools

public static String getRequiredAttribute(Element element, String name) {
  String result = XmlUtil.getAttributeOrNull(element, name);
  if (result == null)
    fail(
      "parsing.missingRequiredAttribute",
      element.getTagName(),
      name);
  return result;
}

代码示例来源:origin: javaee/metro-jax-ws

public static QName getQName(XMLStreamReader reader, String tag){
  String localName = XmlUtil.getLocalPart(tag);
  String pfix = XmlUtil.getPrefix(tag);
  String uri = reader.getNamespaceURI(fixNull(pfix));
  return new QName(uri, localName);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com