Package org.w3c.dom

Examples of org.w3c.dom.NamedNodeMap


      if (
        node.getNodeType() == Node.ELEMENT_NODE
        && NODE_export.equals(node.getNodeName())
        )
      {
        NamedNodeMap nodeAttrs = node.getAttributes();
       
        if (nodeAttrs.getNamedItem(ATTRIBUTE_key) != null)
        {
          exportFonts.put(nodeAttrs.getNamedItem(ATTRIBUTE_key).getNodeValue(), node.getTextContent());
        }
      }
    }
   
    return exportFonts;
View Full Code Here


      else if (
        node.getNodeType() == Node.ELEMENT_NODE
        && NODE_style.equals(node.getNodeName())
        )
      {
        NamedNodeMap nodeAttrs = node.getAttributes();

        Map styleAttrs = new HashMap();

        if (nodeAttrs.getNamedItem(ATTRIBUTE_fontName) != null)
        {
          styleAttrs.put(
            TextAttribute.FAMILY,
            nodeAttrs.getNamedItem(ATTRIBUTE_fontName).getNodeValue()
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_isBold) != null)
        {
          styleAttrs.put(
            TextAttribute.WEIGHT,
            Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isBold).getNodeValue()).booleanValue()
            ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_isItalic) != null)
        {
          styleAttrs.put(
            TextAttribute.POSTURE,
            Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isItalic).getNodeValue()).booleanValue()
            ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_isUnderline) != null)
        {
          styleAttrs.put(
            TextAttribute.UNDERLINE,
            Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isUnderline).getNodeValue()).booleanValue()
            ? TextAttribute.UNDERLINE_ON : null
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_isStrikeThrough) != null)
        {
          styleAttrs.put(
            TextAttribute.STRIKETHROUGH,
            Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isStrikeThrough).getNodeValue()).booleanValue()
            ? TextAttribute.STRIKETHROUGH_ON : null
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_size) != null)
        {
          styleAttrs.put(
            TextAttribute.SIZE,
            new Float(nodeAttrs.getNamedItem(ATTRIBUTE_size).getNodeValue())
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_pdfFontName) != null)
        {
          styleAttrs.put(
            JRTextAttribute.PDF_FONT_NAME,
            nodeAttrs.getNamedItem(ATTRIBUTE_pdfFontName).getNodeValue()
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_pdfEncoding) != null)
        {
          styleAttrs.put(
            JRTextAttribute.PDF_ENCODING,
            nodeAttrs.getNamedItem(ATTRIBUTE_pdfEncoding).getNodeValue()
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_isPdfEmbedded) != null)
        {
          styleAttrs.put(
            JRTextAttribute.IS_PDF_EMBEDDED,
            Boolean.valueOf(nodeAttrs.getNamedItem(ATTRIBUTE_isPdfEmbedded).getNodeValue())
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_forecolor) != null)
        {
          Color color =
            JRColorUtil.getColor(
              nodeAttrs.getNamedItem(ATTRIBUTE_forecolor).getNodeValue(),
              Color.black
              );
          styleAttrs.put(
            TextAttribute.FOREGROUND,
            color
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_backcolor) != null)
        {
          Color color =
            JRColorUtil.getColor(
              nodeAttrs.getNamedItem(ATTRIBUTE_backcolor).getNodeValue(),
              Color.black
              );
          styleAttrs.put(
            TextAttribute.BACKGROUND,
            color
            );
        }

        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_bold.equalsIgnoreCase(node.getNodeName()))
      {
        Map styleAttrs = new HashMap();
        styleAttrs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);

        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_italic.equalsIgnoreCase(node.getNodeName()))
      {
        Map styleAttrs = new HashMap();
        styleAttrs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);

        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_underline.equalsIgnoreCase(node.getNodeName()))
      {
        Map styleAttrs = new HashMap();
        styleAttrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);

        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_sup.equalsIgnoreCase(node.getNodeName()))
      {
        Map styleAttrs = new HashMap();
        styleAttrs.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER);

        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_sub.equalsIgnoreCase(node.getNodeName()))
      {
        Map styleAttrs = new HashMap();
        styleAttrs.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB);

        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_font.equalsIgnoreCase(node.getNodeName()))
      {
        NamedNodeMap nodeAttrs = node.getAttributes();

        Map styleAttrs = new HashMap();

        if (nodeAttrs.getNamedItem(ATTRIBUTE_size) != null)
        {
          styleAttrs.put(
            TextAttribute.SIZE,
            new Float(nodeAttrs.getNamedItem(ATTRIBUTE_size).getNodeValue())
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_color) != null)
        {
          Color color =
            JRColorUtil.getColor(
              nodeAttrs.getNamedItem(ATTRIBUTE_color).getNodeValue(),
              Color.black
              );
          styleAttrs.put(
            TextAttribute.FOREGROUND,
            color
            );
        }

        if (nodeAttrs.getNamedItem(ATTRIBUTE_fontFace) != null)
        {
          String fontFaces = nodeAttrs.getNamedItem(ATTRIBUTE_fontFace).getNodeValue();

          StringTokenizer t = new StringTokenizer(fontFaces, ",");
          while (t.hasMoreTokens())
          {
            String face = t.nextToken().trim();
            if (AVAILABLE_FONT_FACE_NAMES.contains(face))
            {
              styleAttrs.put(TextAttribute.FAMILY, face);
              break;
            }
          }
        }
       
        int startIndex = styledText.length();

        parseStyle(styledText, node);

        styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));

      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_br.equalsIgnoreCase(node.getNodeName()))
      {
        styledText.append("\n");

        int startIndex = styledText.length();
        resizeRuns(styledText.getRuns(), startIndex, 1);

        parseStyle(styledText, node);
        styledText.addRun(new JRStyledText.Run(new HashMap(), startIndex, styledText.length()));

        if (startIndex < styledText.length()) {
          styledText.append("\n");
          resizeRuns(styledText.getRuns(), startIndex, 1);
        }
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_li.equalsIgnoreCase(node.getNodeName()))
      {
        String tmpText = styledText.getText();
        if(tmpText.length() > 0 && !tmpText.endsWith("\n"))
        {
          styledText.append("\n");
        }
        styledText.append(" \u2022 ");

        int startIndex = styledText.length();
        resizeRuns(styledText.getRuns(), startIndex, 1);
        parseStyle(styledText, node);
        styledText.addRun(new JRStyledText.Run(new HashMap(), startIndex, styledText.length()));
       
        // if the text in the next node does not start with a '\n', or
        // if the next node is not a <li /> one, we have to append a new line
        Node nextNode = node.getNextSibling();
        String textContent = getFirstTextOccurence(nextNode);
        if(nextNode != null &&
            !((nextNode.getNodeType() == Node.ELEMENT_NODE &&
                NODE_li.equalsIgnoreCase(nextNode.getNodeName()) ||
            (textContent != null && textContent.startsWith("\n")))
            ))
        {
          styledText.append("\n");
          resizeRuns(styledText.getRuns(), startIndex, 1);
        }
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_a.equalsIgnoreCase(node.getNodeName()))
      {
        if (hyperlink == null)
        {
          NamedNodeMap nodeAttrs = node.getAttributes();

          Map styleAttrs = new HashMap();

          hyperlink = new JRBasePrintHyperlink();
          hyperlink.setHyperlinkType(HyperlinkTypeEnum.REFERENCE);
          styleAttrs.put(JRTextAttribute.HYPERLINK, hyperlink);
         
          if (nodeAttrs.getNamedItem(ATTRIBUTE_href) != null)
          {
            hyperlink.setHyperlinkReference( nodeAttrs.getNamedItem(ATTRIBUTE_href).getNodeValue());
          }

          if (nodeAttrs.getNamedItem(ATTRIBUTE_type) != null)
          {
            hyperlink.setLinkType(nodeAttrs.getNamedItem(ATTRIBUTE_type).getNodeValue());
          }

          if (nodeAttrs.getNamedItem(ATTRIBUTE_target) != null)
          {
            hyperlink.setLinkTarget(nodeAttrs.getNamedItem(ATTRIBUTE_target).getNodeValue());
          }

          int startIndex = styledText.length();

          parseStyle(styledText, node);

          styledText.addRun(new JRStyledText.Run(styleAttrs, startIndex, styledText.length()));
         
          hyperlink = null;
        }
        else
        {
          throw new SAXException("Hyperlink <a> tags cannot be nested.");
        }
      }
      else if (node.getNodeType() == Node.ELEMENT_NODE && NODE_param.equalsIgnoreCase(node.getNodeName()))
      {
        if (hyperlink == null)
        {
          throw new SAXException("Hyperlink <param> tags must appear inside an <a> tag only.");
        }
        else
        {
          NamedNodeMap nodeAttrs = node.getAttributes();

          JRPrintHyperlinkParameter parameter = new JRPrintHyperlinkParameter();
         
          if (nodeAttrs.getNamedItem(ATTRIBUTE_name) != null)
          {
            parameter.setName(nodeAttrs.getNamedItem(ATTRIBUTE_name).getNodeValue());
          }

          if (nodeAttrs.getNamedItem(ATTRIBUTE_valueClass) != null)
          {
            parameter.setValueClass(nodeAttrs.getNamedItem(ATTRIBUTE_valueClass).getNodeValue());
          }

          String strValue = node.getTextContent();
          if (strValue != null)
          {
View Full Code Here

      model.read(new FileInputStream(source), base.toString());
   
    // check that jena has initialised the namespace prefix map
    if (source.getName().endsWith(".rdf")) {
      Document rdf = XMLUtility.read(new FileInputStream(source));
      NamedNodeMap amap = rdf.getDocumentElement().getAttributes();
      Map pmap = model.getNsPrefixMap();
      for (int i=0 ;i<amap.getLength(); i++) {
        Node a = amap.item(i);
        String name = a.getNodeName();
        String lname = a.getLocalName();
        if (name.startsWith("xmlns:") && !pmap.containsKey(lname))
          model.setNsPrefix(lname,a.getNodeValue());
      }
View Full Code Here

    return new DTDAny(property,true);
  }

  public NamedNodeMap getAttributes(XMLBean bean, Document doc)
    throws Exception {
    NamedNodeMap map = super.getAttributes(bean, doc);
    // pcdata properties don't appear as element attributes
    map.removeNamedItem(property);
    return map;
  }
View Full Code Here

    return checkpoint(name1.equals(name2));
  }

  private static boolean equalElementAttributes(Element e1, Element e2) throws Exception {
    boolean eq = true;
    NamedNodeMap attrs = e1.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      Attr a = (Attr) attrs.item(i);
      if (a.getName().startsWith("xmlns")) {
        // ignore namespace declaration
      }
      // xml:lang has no local name to get
      else if (a.getName().equals("xml:lang")) {
View Full Code Here

      Seq s = null;
      // Added extra condition - we should be able to turn off sequencing, risking confusion between attributes and object properties
      if (simple==null && ctx.isSequenced()) s = m.getSeq(obj.addProperty(RDF.type, RDF.Seq));

      // add attributes (and possibly define xmlns)
      NamedNodeMap nm = elem.getAttributes();
      for (int i=0; i<nm.getLength(); i++)
        noSchemaToRDF(obj, (Attr) nm.item(i),ctx);

      // add elements
      NodeList nl = elem.getChildNodes();
      for (int i=0; i<nl.getLength(); i++) {
        switch (nl.item(i).getNodeType()) {
View Full Code Here

   
    ContentIFace content = getContentModel();

    // add attributes

    NamedNodeMap attributes = content.getAttributes(this, doc);
    for (int i = 0; i < attributes.getLength(); i++) {
      Attr a = (Attr) attributes.item(i);
      if (!isDefault(a.getName(), a.getValue()))
        e.setAttributeNodeNS(a);
    }
    NodeList l = content.getChildNodes(this, doc);
    for (int i = 0; i < l.getLength(); i++) {
View Full Code Here

        if (name.startsWith("#")) name=name.substring(1);
        return name; // in the default namespace
      }
    }
    // any matching declarations?
    NamedNodeMap m = e.getAttributes();
    for (int i=0; i<m.getLength(); i++) {
      Attr a = (Attr) m.item(i);
      if (a.getName().startsWith("xmlns:")) {
        String ns = a.getValue();
        if (name.startsWith(ns)) {
          String p = a.getName().substring("xmlns:".length());
          name = name.substring(ns.length());
View Full Code Here

    if (base!=null) {
      String uri = expandQName(ctx.getDefaultNS(),base,ctx.getModel());
      if (uri.startsWith(schema.XSD_URI) && uri.endsWith("#ID")) return getValue(element);
    }
    // check the attributes for ID
    NamedNodeMap m = element.getAttributes();
    // there may be no attributes defined (check for null attribute)
    String id=null;
    for (int i = 0; id==null && _attribute != null && i < _attribute.length; i++) {
      String n = _attribute[i].getName();
      Attr a = (Attr) (n==null?null:m.getNamedItem(n));
      // the attribute may not have any occurrences
      id = _attribute[i].getID(a, ctx);
    }
    return id;
  }
View Full Code Here

    return nl;
  }

  public NamedNodeMap getAttributes(XMLBean bean, Document doc)
    throws Exception {
    NamedNodeMap map = new ContentNamedNodeMap();
    PropertyDescriptor pd[] = bean.info.getPropertyDescriptors();
    for (int i = 0; i < pd.length; i++) {
      if (!pd[i].getPropertyType().isArray()
        && pd[i].getPropertyType() == String.class) {
        Method getter = bean.getGetter(pd[i]);
        String value = (String) getter.invoke(bean, new Object[] {
        });
        if (value != null) {
          Attr attribute = doc.createAttribute(getDisplayName(pd[i]));
          attribute.setValue(value);
          map.setNamedItem(attribute);
        }
      } else if (
        pd[i].getPropertyType().isArray()
          && pd[i].getPropertyType().getComponentType()
            == String.class) {
View Full Code Here

TOP

Related Classes of org.w3c.dom.NamedNodeMap

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.