Package org.w3c.dom

Examples of org.w3c.dom.Node


     * @param value the text to add
     */
    public boolean setNodeText(Document domDocument, Node n, String value) {
        if (n == null)
            return false;
        Node nc = null;
        while ((nc = n.getFirstChild()) != null) {
            n.removeChild(nc);
        }
        n.appendChild(domDocument.createTextNode(value));
        return true;
View Full Code Here


     */
  public byte[] serializeDoc() throws IOException {
    XmlDomWriter xw = new XmlDomWriter();
        ByteArrayOutputStream fout = new ByteArrayOutputStream();
        xw.setOutput(fout, null);
        Node first = domDocument.getFirstChild();
        xw.write(first);
        fout.write('\n');
        xw.write(first.getNextSibling());
        fout.flush();
    for (int i = 0; i < 20; i++) {
      fout.write(XmpWriter.EXTRASPACE.getBytes());
    }
        xw.write(domDocument.getLastChild());
View Full Code Here

      DocumentBuilder parser = factory.newDocumentBuilder();
      Document document = parser.parse(is);
      NodeList nodes = document.getElementsByTagName("locale-config");
      for (int i = 0; i < nodes.getLength(); i++)
      {
         Node node = nodes.item(i);
         NodeList children = node.getChildNodes();
         LocaleConfig config = new LocaleConfigImpl();
         for (int j = 0; j < children.getLength(); j++)
         {
            Node element = children.item(j);
            if ("locale".equals(element.getNodeName()))
            {
               config.setLocale(element.getFirstChild().getNodeValue());
            }
            else if ("output-encoding".equals(element.getNodeName()))
            {
               config.setOutputEncoding(element.getFirstChild().getNodeValue());
            }
            else if ("input-encoding".equals(element.getNodeName()))
            {
               config.setInputEncoding(element.getFirstChild().getNodeValue());
            }
            else if ("description".equals(element.getNodeName()))
            {
               config.setDescription(element.getFirstChild().getNodeValue());
            }
            else if ("orientation".equals(element.getNodeName()))
            {
               String s = element.getFirstChild().getNodeValue();
               Orientation orientation = orientations.get(s);
               if (orientation == null)
               {
                  log.error("Wrong orientation value " + s);
               }
View Full Code Here

              // normalize text representation
            doc.getDocumentElement ().normalize ();
            NodeList listOfResults = doc.getElementsByTagName("Result");
            for(int i= 0; i< listOfResults.getLength(); i++){
                   ResultGeoCodeApi result = new ResultGeoCodeApi();
                   Node nodeResult = listOfResults.item(i);
                   if(nodeResult.getNodeType() == Node.ELEMENT_NODE){
                    Element elementResult = (Element)nodeResult;
                    result.setPrecision(elementResult.getAttribute("precision"));

                   
                    NodeList latitudes = elementResult.getElementsByTagName("Latitude");
View Full Code Here

    /**
     * @param e
     */
    protected Element getParentForm(Element e, LayoutContext context) {
        Node node = e;

        do {
            node = node.getParentNode();
        } while (node.getNodeType() == Node.ELEMENT_NODE &&
                !context.getNamespaceHandler().isFormElement((Element) node));

        if (node.getNodeType() != Node.ELEMENT_NODE) {
            return null;
        }

        return (Element) node;
    }
View Full Code Here

        List list = new ArrayList();
        //get the processing-instructions (actually for XmlDocuments)
        //type and href are required to be set
        NodeList nl = doc.getChildNodes();
        for (int i = 0, len = nl.getLength(); i < len; i++) {
            Node node = nl.item(i);
            if (node.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) continue;
            ProcessingInstruction piNode = (ProcessingInstruction) node;
            if (!piNode.getTarget().equals("xml-stylesheet")) continue;
            StylesheetInfo info = new StylesheetInfo();
            info = new StylesheetInfo();
            info.setOrigin(StylesheetInfo.AUTHOR);
View Full Code Here

  public List<Element> elements(Element e, String name) {
    List<Element> eList = new ArrayList<Element>();

    NodeList nodeList = e.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); ++i) {
      Node node = nodeList.item(i);
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        if (name != null) {
          if (node.getNodeName().equals(name))
            eList.add((Element) node);
        } else {
          eList.add((Element) node);
        }
      }
View Full Code Here

  public String getTextValue(Element valueEle) {
    if (valueEle != null) {
      StringBuilder sb = new StringBuilder();
      NodeList nl = valueEle.getChildNodes();
      for (int i = 0; i < nl.getLength(); i++) {
        Node item = nl.item(i);
        if ((item instanceof CharacterData && !(item instanceof Comment))
            || item instanceof EntityReference) {
          sb.append(item.getNodeValue());
        }
      }
      return sb.toString().trim();
    }
    return null;
View Full Code Here

        CalculatedStyle result = null;
        if (! restyle) {
            result = (CalculatedStyle)styleMap.get(e);
        }
        if (result == null) {
            Node parent = e.getParentNode();
            CalculatedStyle parentCalculatedStyle;
            if (parent instanceof Document) {
                parentCalculatedStyle = new EmptyStyle();
            } else {
                parentCalculatedStyle = getStyle((Element)parent, false);
View Full Code Here

        JOptionPane.showMessageDialog(null, "Check System.out for the submitted content.", "Form Submission", JOptionPane.INFORMATION_MESSAGE);
    }

    public static String collectText(Element e) {
        StringBuffer result = new StringBuffer();
        Node node = e.getFirstChild();
        if (node != null) {
            do {
                short nodeType = node.getNodeType();
                if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
                    Text text = (Text) node;
                    result.append(text.getData());
                }
            } while ((node = node.getNextSibling()) != null);
        }
        return result.toString().trim();
    }
View Full Code Here

TOP

Related Classes of org.w3c.dom.Node

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.