Package com.sun.xml.tree

Examples of com.sun.xml.tree.XmlDocument$DocFragNode


      builder.setParser(parser);

      // get the message and parse
      String msgText = ((TextMessage) message).getText();
      parser.parse(new InputSource(new StringReader(msgText)));
      XmlDocument doc =  (XmlDocument) builder.getDocument();
      Element root =  doc.getDocumentElement();

      if (root.getAttribute("message").equalsIgnoreCase("quit")) {
        synchronized(this) {
          quit = true;
          this.notifyAll(); // Notify main thread to quit
        }
      } else {

        System.out.println("\n\nYou have a message in you inbox!");
        System.out.println("From: "+ root.getAttribute("sender"));
        System.out.println("Message: "+ root.getAttribute("message"));
        System.out.println("Status of message: "+ root.getAttribute("status"));

        if (root.getAttribute("status").equals("pending approval")) {
          boolean approved = false;
          boolean denied = false;

          do {
            System.out.print("Approve (\"yes\" or \"no\"): ");

            BufferedReader msgStream = new BufferedReader(new InputStreamReader(System.in));
            String line=null;
            line = msgStream.readLine();
            if (line != null && line.trim().length() != 0) {
              approved = line.equalsIgnoreCase("yes");
              denied = line.equalsIgnoreCase("no");
              if (approved || denied) {
                msg.setStringProperty("messageTo", root.getAttribute("sender"));
   
                // update the original xml doc
                root.setAttribute("status", approved ? "approved" : "approval denied");
                root.setAttribute("sender", "Admin");

                // send xml doc back to JMS queue
                StringWriter sw = new StringWriter();
                doc.write(sw);
                msg.setText(sw.toString());
                System.out.println("Message status updated. Returning message to sender.");
                qsender.send(msg);
              }
            }
View Full Code Here


   */
  public void send(String message, String status, String sendTo)
       throws JMSException
  {
    // create a new XML document
    XmlDocument xmlDoc = new XmlDocument();

    // set the document type declaration
    xmlDoc.setDoctype(
      "weblogic-examples-xml-jms-dtd",
      "http://www.wegblogic.com/docs51/examples/xml/jms/workflow.dtd",
      "");

    // assign elements and attributes
    Element root = xmlDoc.createElement("workflow");
    root.setAttribute("message", message);
    root.setAttribute("sender", username);
    root.setAttribute("status", status);
    xmlDoc.appendChild(root);
   
    // write document to a String and send as a JMS text message
    StringWriter sw = new StringWriter();
    try {
      xmlDoc.write(sw);
      msg.setText(sw.toString());
      msg.setStringProperty("messageTo", sendTo);
      qsender.send(msg);
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  else{
      stylesheetUrl = new URL(Http + stylesheetName + ".xsl");
  }
  System.out.println(stylesheetUrl.toString());
  InputStream stylesheetStream = stylesheetUrl.openStream();
  XmlDocument sheet = XmlDocument.createXmlDocument(stylesheetStream,
                false);
  return _transformEngine.createTransform(sheet);
    }
View Full Code Here

   *
   * @param location Location of the file.
   * @return Loaded project.
   */
    public ACSProjectElement load(URL location) throws IOException {
        XmlDocument doc = null;

        try {
            SAXParser sax = SAXParserFactory.newInstance().newSAXParser();
            Parser parser = (Parser) sax.getParser();
            XmlDocumentBuilder builder = new XmlDocumentBuilder();
            builder.setIgnoringLexicalInfo(false);
            SimpleElementFactory fact = new SimpleElementFactory();
            fact.addMapping(_elementMap, ACSFactory.class.getClassLoader());

            builder.setElementFactory(fact);
           
            parser.setDocumentHandler(builder);
            parser.setEntityResolver(new Resolver());
            //parser.setErrorHandler();

            sax.parse(location.openStream(), null);

            doc = builder.getDocument();

        }
        catch(ParserConfigurationException ex) {
            ex.printStackTrace();
            throw new IOException(ex.getMessage());
        }
        catch(SAXException ex) {
            ex.printStackTrace();
            throw new IOException(ex.getMessage());
        }

        return (ACSProjectElement) doc.getDocumentElement();
    }
View Full Code Here

     * @return Empty project.
     */
    public ACSProjectElement createProject() {
        SimpleElementFactory fact = new SimpleElementFactory();
        fact.addMapping(_elementMap, ACSFactory.class.getClassLoader());
        XmlDocument doc = new XmlDocument();
        doc.setElementFactory(fact);
        return (ACSProjectElement) doc.createElement("project");
    }
View Full Code Here

    private final void initXmlProcessor() throws Exception {
  _transformEngine = new MyXslEngine();
   
  URL stylesheetUrl = new URL(Http + "default.xsl");
  InputStream stylesheetStream = stylesheetUrl.openStream();
  XmlDocument sheet = XmlDocument.createXmlDocument(stylesheetStream,
                false);
  _defaultTransform = _transformEngine.createTransform(sheet);
  _treeBuilder = new TreeBuilder(_transformEngine.getNameTable());
  _treeResult = new TreeResult(_transformEngine.getNameTable());
View Full Code Here

      if (value != null)
    return (Transform)value;
      else {
    System.out.println("creating transform: " + stylesheetUrl);
    InputStream stylesheetStream = stylesheetUrl.openStream();
    XmlDocument sheet =
        XmlDocument.createXmlDocument(stylesheetStream, false);
    Transform transform = _transformEngine.createTransform(sheet);
    _transformCache.put(stylesheetUrl, transform);
    return transform;
      }
View Full Code Here

    }
   
    private void parseCfg(URL cfgFileLocation)
  throws IOException, SAXException {
  InputSource input = Resolver.createInputSource(cfgFileLocation, true);
  XmlDocument document = XmlDocument.createXmlDocument(input, false);
  Element catalog = document.getDocumentElement();
  NodeList list = catalog.getElementsByTagName("DocType");
  final int listLength = list.getLength();
  for(int i = 0; i < listLength; i++){
      Element docTypeEl = (Element)list.item(i);
      _types.put(docTypeEl.getAttribute("type"), docTypeEl);
View Full Code Here

  private final void initXmlProcessor() throws Exception {
    _transformEngine = new XSLTransformEngine();
   
    URL stylesheetUrl = new URL(Http + "default.xsl");
    InputStream stylesheetStream = stylesheetUrl.openStream();
    XmlDocument sheet = XmlDocument.createXmlDocument(stylesheetStream, false);
    _defaultTransform = _transformEngine.createTransform(sheet);
    _treeBuilder = new TreeBuilder(_transformEngine.getNameTable());
    _treeResult = new TreeResult(_transformEngine.getNameTable());

    _StartHighlight_Name = getElementName("StartHighlight");
View Full Code Here

      if (value != null)
  return (Transform)value;
      else {
  System.out.println("creating transform: " + stylesheetUrl);
  InputStream stylesheetStream = stylesheetUrl.openStream();
  XmlDocument sheet = XmlDocument.createXmlDocument(stylesheetStream, false);
  Transform transform = _transformEngine.createTransform(sheet);
  _transformCache.put(stylesheetUrl, transform);
  return transform;
      }
    }
View Full Code Here

TOP

Related Classes of com.sun.xml.tree.XmlDocument$DocFragNode

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.