Package org.w3c.dom

Examples of org.w3c.dom.Attr


    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


        && 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()
View Full Code Here

    if (restrictions!=null) return;
   
    schema xs = (schema) this.get_owner();
    NamedNodeMap atts = node.getAttributes();
    for (int i=0; i<atts.getLength(); i++) {
      Attr attr = (Attr) atts.item(i);
      if (attr.getNodeName().startsWith("xmlns")) continue;
      String ns = attr.getNamespaceURI();
      StringTokenizer t = new StringTokenizer(namespace);
      while (t.hasMoreTokens()) {
        String n = t.nextToken();
        String tns = xs.getTargetNamespace();
        if (n.equals("##any") // anything at all
        || (n.equals("##other") && (tns==null || !tns.equals(ns))) // other than the TNS
        || (n.equals("##targetNamespace") && (tns==null || tns.equals(ns))) // in the target namespace
        || (n.equals("##local") && ns==null) // local to this schema
        || n.equals(ns) ) { // else the ns is anyURI
          // is this a known attribute?
          String uri = attribute.createURI(attr,null,ctx);
          attribute a = ctx.getAttribute(uri);
          if (a!=null) {
            a.toRDF(subject, attr, ctx);
            if (attr.getPrefix()!=null)
              addPrefixes(attr.getPrefix(), attr.getNamespaceURI(), ctx.getModel());
          }
          else { // otherwise use the default no-schema mapping
            if (getProcessContents().equals("strict")
                && !n.equals("##any") && !n.equals("##other") && !n.equals("##local"))
              Gloze.logger.warn("cannot find attribute: "+attr.getName());
            noSchemaToRDF(subject,attr,ctx);
          }
        }
      }
    }
View Full Code Here

        if (namespace.contains("##any") ||
              (namespace.contains("##other") && !ns.equals(xs.getTargetNamespace())) ||
            (namespace.contains("##local") ||
            namespace.contains(ns) || namespace.contains(nsAlt))) {
         
          Attr attr;
          if (qualify && !(ns.equals(ctx.getDefaultNS()) || ctx.getDefaultNS().equals(nsAlt))) {
            attr = doc.createAttributeNS(ns, p.getLocalName());
            attr.setPrefix(pref)
          }
          else attr = doc.createAttribute(p.getLocalName());
          attr.setNodeValue(s.getString());
          if (qualify) e.setAttributeNodeNS(attr);
          else e.setAttributeNode(attr);
        }
        done.add(s);
      }
View Full Code Here

  private void toXML(Element e, Context ctx, attribute def, String type, RDFNode object)
    throws Exception {
      Document doc = e.getOwnerDocument();
      schema xs = (schema) this.get_owner();
      Attr a;
      if (isQualified()) {
        String ns = xs.getTargetNamespace();
        a = doc.createAttributeNS(ns, def.getName());
        //if (Character.isLetterOrDigit(ns.charAt(ns.length()-1))) ns += "#";
        a.setPrefix(ctx.getModel().getNsURIPrefix(ns));
        e.setAttributeNodeNS(a);
      }
      else e.setAttributeNode(a = doc.createAttribute(def.getName()));

      XMLBean t = get_type(ctx);
      if (t instanceof simpleType) ((simpleType) t).toXML(a,object,ctx);
      else if (type != null && type.endsWith("IDREFS"))
        xs.listToXML(a,(RDFList) object.as(RDFList.class),XSD.IDREF.getURI(),ctx);
      else a.setValue(xs.toXMLValue(e,object,type,ctx));
    }
View Full Code Here

    // check the attributes for ID
    NamedNodeMap m = element.getAttributes();
    // there may be no attributes defined (check for null attribute)
    for (int i = 0; _attribute != null && i < _attribute.length; i++) {
      String id = null;
      Attr a = (Attr) m.getNamedItem(_attribute[i].getDefinition(ctx.getModel(),ctx).getName());
      // the attribute may not have any occurrences
      if (a != null) id = _attribute[i].getID(a,ctx);
      if (id != null) return id;
    }
    // look for attributes embedded within simple content declaration
View Full Code Here

    if (!resource.isAllDocument())
    {
      Node node = resource.getSelectedResource().getDom();
      if (node instanceof Attr)
      {
        Attr attr = (Attr) node;
        attr.getOwnerElement().removeAttribute(node.getLocalName());
      }
      else
      {
        node.getParentNode().removeChild(node);
      }
View Full Code Here

        Element element = (Element) parent.getDom();
        element.setAttribute(resource.getNodeName(), content);
      }
      else
      {
        Attr attr = (Attr) resource.getSelectedResource().getDom();
        attr.setValue(content);
      }
    }
    else
    {
      Document document = null;
View Full Code Here

  }
 
  private void add(XmlCursor source, XmlCursor destination)
  {
    NodeList nodeList = destination.getDomNode().getChildNodes();
    Attr idNode = (Attr) source.getDomNode().getAttributes().getNamedItem("id");
    if (idNode != null)
    {
      for (int i = 0; i < nodeList.getLength(); i++)
      {
        Node node2 = nodeList.item(i);
        Attr idNode2 = (Attr) (node2.getAttributes() != null ? node2.getAttributes().getNamedItem("id") : null);
        if (node2.getNodeName().equals(source.getDomNode().getNodeName())
            && idNode2 != null && idNode.getValue().equals(idNode2.getValue()))
        {
          __log.warn("Got two nodes with same id: {}. Ignore second node.", idNode.getValue());
          return;
        }
      }
View Full Code Here

      iter = XPath.select("//xtp:directive.page/@*", top);
    } catch (Exception e) {
      throw new XslParseException(e);
    }
    while (iter.hasNext()) {
      Attr attr = (Attr) iter.next();
      String name = attr.getNodeName();
      String value = attr.getNodeValue();

      if (name.equals("import")) {
        StringCharCursor cursor = new StringCharCursor(value);
        CharBuffer cb = new CharBuffer();
        while (cursor.current() != cursor.DONE) {
View Full Code Here

TOP

Related Classes of org.w3c.dom.Attr

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.