Package javax.xml.parsers

Examples of javax.xml.parsers.DocumentBuilder


        try {
            WebService ws = serviceImplementation.getClass().getAnnotation(WebService.class);
            if (ws != null) {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                factory.setNamespaceAware(true);
                DocumentBuilder builder = factory.newDocumentBuilder();
                doc = builder.parse(ws.wsdlLocation());
            } else {
                LOG.severe("could not get WebService annotation from " + serviceImplementation);
            }
        } catch (Exception ex) {
            ex.printStackTrace();


        File metaInf = new File(rootPath, "META-INF");
        File jbiXml = new File(metaInf, "jbi.xml");
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document doc = builder.parse(jbiXml.toURL().toString());
           
            Element providesEl = (Element)findNode(doc.getDocumentElement(), "provides");
            endpointName = providesEl.getAttribute("endpoint-name");
        } catch (Exception ex) {
            LOG.log(Level.SEVERE, "error parsing " + jbiXml, ex);

        try {
            JBIOutputStreamMessageContext jbiCtx = (JBIOutputStreamMessageContext)msgContext;
            ByteArrayOutputStream baos = (ByteArrayOutputStream)jbiCtx.getOutputStream();
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            LOG.finest("building document from bytes");
            DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
            Document doc = builder.parse(bais);
           
            MessageExchange xchng = (MessageExchange)ctx.get(MESSAGE_EXCHANGE_PROPERTY);
            LOG.fine("creating NormalizedMessage");
            NormalizedMessage msg = xchng.createMessage();
            msg.setContent(new DOMSource(doc));

                                                    boolean namespaceAware) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(validating);
    factory.setNamespaceAware(namespaceAware);

    DocumentBuilder builder = factory.newDocumentBuilder();

    return builder.newDocument();
  }

      //input.setSystemId("9999999999");
      final String ME = "DOMParser";
      if (glob == null) glob = Global.instance();
      try {
         DocumentBuilderFactory dbf = glob.getDocumentBuilderFactory();
         DocumentBuilder db = dbf.newDocumentBuilder();
         return db.parse(input);
      } catch (javax.xml.parsers.ParserConfigurationException e) {
         log.severe("Problems when building DOM parser: " + e.toString() + "\n" + xmlKey_literal);
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME, "Problems when building DOM tree from your XML-ASCII string\n" + xmlKey_literal, e);
      } catch (java.io.IOException e) {
         log.severe("Problems when building DOM tree from your XML-ASCII string: " + e.toString() + "\n" + xmlKey_literal);

            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_CSV, "7");
      }
      try
      {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder();

        Document doc = builder.parse(descriptionFile);
        XDomSupport.deleteWhitespaceTextInElementNodesAndComments(doc);
        setDescriptionTree(doc);
      }
      catch (Exception e)
      {

   * @return The parsed DOM tree.
   * @throws XException
   */
  public Document parse(String text, String systemName) throws XException
  {
    DocumentBuilder builder = null;
    try
    {
      builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    }
    catch (Exception e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL, Constants.PACKAGE_PROTOCOL_CSV,
          "13");
    }
    Document resultDocument = builder.newDocument();

    // create root node <i>systemName</i>
    Element root = resultDocument.createElement(systemName);
    resultDocument.appendChild(root);


   */
  private Document parseRecords(Object interfaceContent,
      int interfaceContentClass, XBUSSystem system) throws XException
  {
    Document retDocument;
    DocumentBuilder builder = getDocumentBuilder(system);
    retDocument = builder.newDocument();
    // for the parsed content
    RecordTypeParser rtParser = RecordTypeParser.getInstance(getSource()
        .getName(), interfaceContentClass);
    // Get a parser object


      if (rtSerializer.getSourceType() == null
          || !rtSerializer.getSourceType().equals(sourceType)
          || rtSerializer.getInterfaceContentClass() != interfaceContentClass)
      { // Serializer is not yet initialised for the correct interface
        // file type
        DocumentBuilder builder = getDocumentBuilder(system);
        rtSerializer.initialize(sourceType, interfaceContentClass,
            builder);
      } // if (rtSerializer.getSourceType()==null ||
      // !rtSerializer.getSourceType().equals(contentType))
      // Serializer is initialized, so let's go.

   *             <code>DocumentBuilder</code> object arises
   */
  static public DocumentBuilder getDocumentBuilder(String messageName,
      String system) throws XException
  {
    DocumentBuilder docBuilder;

    if (messageName == null)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_COREBASE, Constants.PACKAGE_COREBASE_XML,
          "2");
    }

    try
    // to cast to XException
    {
      DocumentBuilderFactory factory = DocumentBuilderFactory
          .newInstance();
      factory
          .setIgnoringComments(getIgnoringComments(messageName,
              system));
      factory
          .setIgnoringElementContentWhitespace(getIgnoringElementContentWhitespace(
              messageName, system));
      factory.setValidating(getValidating(messageName, system));
      factory.setNamespaceAware(getNamespaceAware(messageName, system));

      docBuilder = factory.newDocumentBuilder();
      docBuilder.setErrorHandler(new XParserErrorHandler());
    } // try
    catch (ParserConfigurationException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_COREBASE, Constants.PACKAGE_COREBASE_XML,

TOP

Related Classes of javax.xml.parsers.DocumentBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.