Package org.apache.xerces.xni

Examples of org.apache.xerces.xni.XMLAttributes.addAttribute()


         // if an inheritable attribute doesn't already exist in the attributes list, add it to the list
         if (!attributeExists(ctaAttributes, inhAttr)) {
            String rawName = "".equals(inhAttr.getPrefix()) ? inhAttr.getLocalName() : inhAttr.getPrefix() + ":" +
                                       inhAttr.getLocalName();
            fTempQName.setValues(inhAttr.getPrefix(), inhAttr.getLocalName(), rawName, inhAttr.getUri());
            ctaAttributes.addAttribute(fTempQName, inhAttr.getType(), inhAttr.getValue());
         }
      }
     
      return ctaAttributes;
     


                //Create XMLAttributes from DOM
                Attr[] atts = (Element) child == null ? null : DOMUtil.getAttrs((Element) child);
                XMLAttributes attrs = new XMLAttributesImpl();
                for (int i=0; i<atts.length; i++) {
                    Attr att = (Attr)atts[i];
                    attrs.addAttribute(
                            new QName(att.getPrefix(), att.getLocalName(), att.getName(), att.getNamespaceURI()),
                            "CDATA" ,att.getValue()
                            );
                }

        if (atts != null) {
            for (int i = 0; i < atts.size(); i += 3) {
                String rawname = (String)atts.elementAt(i);
                String value = (String)atts.elementAt(i + 1);
                String type = (String)atts.elementAt(i + 2);
                attributes.addAttribute(createQName(rawname), type, value);
            }
        }
        return attributes;
    }

      // copy attributes from the original list of attributes
      XMLAttributes ctaAttributes = new XMLAttributesImpl();
      for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
         QName qName = new QName();
         attributes.getName(attrIndx, qName);
         ctaAttributes.addAttribute(qName, attributes.getType(attrIndx),
                                    attributes.getValue(attrIndx));  
      }
     
      // traverse up the XML tree, to find inherited attributes.
      // attributes only from the nearest ancestor, are added to the list

         // list, add it to the list.
         if (!attributeExists(ctaAttributes, inhAttr)) {
            String rawName = "".equals(inhAttr.getPrefix()) ? inhAttr.getLocalName() :
                                   inhAttr.getPrefix() + ":" + inhAttr.getLocalName();
            fTempQName.setValues(inhAttr.getPrefix(), inhAttr.getLocalName(), rawName, inhAttr.getUri());
            ctaAttributes.addAttribute(fTempQName, inhAttr.getType(), inhAttr.getValue());
         }
      }
     
      return ctaAttributes;
     

                        attributes.getName(i, aqname);
                        String type = attributes.getType(i);
                        String value = attributes.getValue(i);
                        String nonNormalizedValue = attributes.getNonNormalizedValue(i);
                        boolean specified = attributes.isSpecified(i);
                        newattrs.addAttribute(aqname, type, value);
                        newattrs.setNonNormalizedValue(i, nonNormalizedValue);
                        newattrs.setSpecified(i, specified);
                    }
                    this.attributes = newattrs;
                }

    }

    private void insertStyle(String style, String className) {
      QName element = new QName(null, "link", "link", null);
      XMLAttributes attrs = new XMLAttributesImpl();
      attrs.addAttribute(new QName(null, "href", "href", null),
          "CDATA", style);
      attrs.addAttribute(new QName(null, "type", "type", null),
          "CDATA", "text/css");
      attrs.addAttribute(new QName(null, "rel", "rel", null),
          "CDATA", "stylesheet");

    private void insertStyle(String style, String className) {
      QName element = new QName(null, "link", "link", null);
      XMLAttributes attrs = new XMLAttributesImpl();
      attrs.addAttribute(new QName(null, "href", "href", null),
          "CDATA", style);
      attrs.addAttribute(new QName(null, "type", "type", null),
          "CDATA", "text/css");
      attrs.addAttribute(new QName(null, "rel", "rel", null),
          "CDATA", "stylesheet");
      attrs.addAttribute(new QName(null, "class", "class", null),
          "CDATA", className);

      XMLAttributes attrs = new XMLAttributesImpl();
      attrs.addAttribute(new QName(null, "href", "href", null),
          "CDATA", style);
      attrs.addAttribute(new QName(null, "type", "type", null),
          "CDATA", "text/css");
      attrs.addAttribute(new QName(null, "rel", "rel", null),
          "CDATA", "stylesheet");
      attrs.addAttribute(new QName(null, "class", "class", null),
          "CDATA", className);
      Augmentations augs = new HTMLAugmentations();
      super.emptyElement(element, attrs, augs);

          "CDATA", style);
      attrs.addAttribute(new QName(null, "type", "type", null),
          "CDATA", "text/css");
      attrs.addAttribute(new QName(null, "rel", "rel", null),
          "CDATA", "stylesheet");
      attrs.addAttribute(new QName(null, "class", "class", null),
          "CDATA", className);
      Augmentations augs = new HTMLAugmentations();
      super.emptyElement(element, attrs, augs);
    }

TOP
Copyright © 2018 www.massapi.com. 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.