Get metadata elements to add to current document. Elements have been cloned and imported
into the current document.

@param cls element class of metadata elements
@param doc current document
@return list of metadata elements, may be empty
768072
private List<Element> getNewChildren(final DitaClass cls, final Document doc) {
        final List<Element> res = new ArrayList<>();
        if (metaTable.containsKey(cls.matcher)) {
            metaTable.get(cls.matcher);
            final NodeList list = metaTable.get(cls.matcher).getChildNodes();
            for (int i = 0; i < list.getLength(); i++) {
                Node item = list.item(i);
                res.add((Element) doc.importNode(item, true));
            }
        }
        Collections.reverse(res);
        return res;
    }
187945
public static Node[] toNodeArray(Document doc, Object o) throws PageException {
	if (o instanceof Node) return new Node[] { (Node) o };
	// Node[]
	if (o instanceof Node[]) {
	    return (Node[]) o;
	}
	// Collection
	else if (o instanceof Collection) {
	    Collection coll = (Collection) o;
	    Iterator<Object> it = coll.valueIterator();
	    List<Node> nodes = new ArrayList<Node>();
	    while (it.hasNext()) {
		nodes.add(toNode(doc, it.next(), false));
	    }
	    return nodes.toArray(new Node[nodes.size()]);
	}
	// Node Map and List
	Node[] nodes = _toNodeArray(doc, o);
	if (nodes != null) return nodes;
	// Single Text Node
	try {
	    return new Node[] { toNode(doc, o, false) };
	}
	catch (ExpressionException e) {
	    throw new XMLException("can't cast Object of type " + Caster.toClassName(o) + " to a XML Node Array");
	}
    }
862223
public Map<String, String> getDocumentMetadata(InputStream docIS) {
        Map<String, String> metadata = new HashMap<String, String>();

        try {
            // Create instance of DocumentBuilderFactory
            DocumentBuilderFactory factory =
                    DocumentBuilderFactory.newInstance();
            // Get the DocumentBuilder
            DocumentBuilder docBuilder = factory.newDocumentBuilder();
            // Create blank DOM Document and parse contents of input stream
            Document doc = docBuilder.parse(docIS);

            NodeList nodes = null;

            metadata.put("PolicyId", doc.getDocumentElement()
                    .getAttribute("PolicyId"));

            nodes = doc.getElementsByTagName("Subjects");
            if (nodes.getLength() == 0) {
                metadata.put("anySubject", "T");
            }

            nodes = doc.getElementsByTagName("Resources");
            if (nodes.getLength() == 0) {
                metadata.put("anyResource", "T");
            }

            nodes = doc.getElementsByTagName("Actions");
            if (nodes.getLength() == 0) {
                metadata.put("anyAction", "T");
            }

            nodes = doc.getElementsByTagName("Environments");
            if (nodes.getLength() == 0) {
                metadata.put("anyEnvironment", "T");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }

        return metadata;
    }
737660
function(doc) {
        if (typeof doc == "string") { 
            doc = OpenLayers.Format.XML.prototype.read.apply(this, [doc]);
        }
        var features = [];
        
        if(this.extractTracks) {
            var tracks = doc.getElementsByTagName("trk");
            for (var i=0, len=tracks.length; i<len; i++) {
                // Attributes are only in trk nodes, not trkseg nodes
                var attrs = {};
                if(this.extractAttributes) {
                    attrs = this.parseAttributes(tracks[i]);
                }
                
                var segs = this.getElementsByTagNameNS(tracks[i], tracks[i].namespaceURI, "trkseg");
                for (var j = 0, seglen = segs.length; j < seglen; j++) {
                    // We don't yet support extraction of trkpt attributes
                    // All trksegs of a trk get that trk's attributes
                    var track = this.extractSegment(segs[j], "trkpt");
                    features.push(new OpenLayers.Feature.Vector(track, attrs));
                }
            }
        }
        
        if(this.extractRoutes) {
            var routes = doc.getElementsByTagName("rte");
            for (var k=0, klen=routes.length; k<klen; k++) {
                var attrs = {};
                if(this.extractAttributes) {
                    attrs = this.parseAttributes(routes[k]);
                }
                var route = this.extractSegment(routes[k], "rtept");
                features.push(new OpenLayers.Feature.Vector(route, attrs));
            }
        }
        
        if(this.extractWaypoints) {
            var waypoints = doc.getElementsByTagName("wpt");
            for (var l = 0, len = waypoints.length; l < len; l++) {
                var attrs = {};
                if(this.extractAttributes) {
                    attrs = this.parseAttributes(waypoints[l]);
                }
                var wpt = new OpenLayers.Geometry.Point(waypoints[l].getAttribute("lon"), waypoints[l].getAttribute("lat"));
                features.push(new OpenLayers.Feature.Vector(wpt, attrs));
            }
        }
        
        if (this.internalProjection && this.externalProjection) {
            for (var g = 0, featLength = features.length; g < featLength; g++) {
                features[g].geometry.transform(this.externalProjection,
                                    this.internalProjection);
            }
        }
        
        return features;
    }
252363
public static Map<String, Object> bodyOfSelectedRevision(Document doc) {
        byte[] body;
        try {
            body = doc.getSelectedBody();
        } catch (ForestException e) {
            return null;
        }
        Map<String, Object> properties = null;
        if (body != null && body.length > 0) {
            try {
                properties = Manager.getObjectMapper().readValue(body, Map.class);
            } catch (IOException e) {
                Log.w(TAG, "Failed to parse body: [%s]", new String(body));
            }
        }
        return properties;
    }
204929
public Node cloneNode(Document doc, Node eold) {
    return doc.importNode(eold, true);
  }
1162013
public JSDocInfo cloneClassDoc() {
    JSDocInfo other = new JSDocInfo();
    other.info = this.info == null ? null : this.info.cloneClassDoc();
    other.documentation = this.documentation;
    other.visibility = this.visibility;
    other.bitset = this.bitset;
    other.type = cloneType(this.type, false);
    other.thisType = cloneType(this.thisType, false);
    other.includeDocumentation = this.includeDocumentation;
    other.originalCommentPosition = this.originalCommentPosition;
    other.setConstructor(false);
    other.setStruct(false);
    if (!isInterface() && other.info != null) {
      other.info.baseType = null;
    }
    return other;
  }
1279521
def collect_navigation_properties(klass_name, element, doc)
    nav_props = element.xpath(".//edm:NavigationProperty", @ds_namespaces)
    @class_metadata[klass_name].merge!(build_property_metadata(nav_props))
    nav_props.collect { |p| p['Name'] }
  end
697516
private function getDocumentActualData(ClassMetadata $class, $document)
    {
        $actualData = [];
        foreach ($class->reflFields as $fieldName => $reflProperty) {
            // do not set the version info fields if they have values, they are not to be managed by the user in write scenarios.
            if ($fieldName === $class->versionNameField
                || $fieldName === $class->versionCreatedField
            ) {
                continue;
            }
            $value = $reflProperty->getValue($document);
            $actualData[$fieldName] = $value;
        }

        return $actualData;
    }
747784
private final Field[] getFields (Class<? extends Object> cls) {
    	Field[] ret = SEEN_CLASSES.get(cls);
        if (ret != null) {
            return ret;
        }

        List<Field> retL = new ArrayList<Field>();
        for (Field f: cls.getDeclaredFields ()) {
        	if (!isSimpleType(f)) {
        		retL.add(f);
        		f.setAccessible(true);
        	}
        }

        //the 2nd case can occur if the incoming object is of type Object.class
        //--> See Test_084_SerailizationBugRefToPM.
        if (cls.getSuperclass() != Object.class && cls != Object.class) {
        	for (Field f: getFields(cls.getSuperclass())) {
        		retL.add(f);
        	}
        }
        ret = retL.toArray(new Field[retL.size()]);
        SEEN_CLASSES.put(cls, ret);
        return ret;
    }
676294
@SuppressWarnings("unchecked")
    public final FindableDocument<? extends GedObject, ? extends GedDocument<?>>
        get(final Class<? extends GedObject> clazz) {
        return (FindableDocument<? extends GedObject, ? extends GedDocument<?>>)
                classToRepoMap .get(clazz);
    }
35532
def get_meta(doc)
      meta = doc.xpath("//meta/*").each_with_object({}) do |node, meta|
        meta[node.name] = node.text
      end
    end
788927
public static Type[] getGenerics(Class cls) {
		$.checkNotNull(cls);

		Type genType = cls.getGenericSuperclass();
		if (genType instanceof ParameterizedType) {
			return ((ParameterizedType) genType).getActualTypeArguments();
		}

		return null;
	}
423148
def add_meta(doc, obj)
      meta = get_meta(doc)
      obj.define_singleton_method(:meta) { meta } && obj
    end
599675
private String fetchStyles(Document doc) {
        Elements els = doc.select(STYLE_TAG);
        StringBuilder styles = new StringBuilder();
        for (Element e : els) {
            if (e.attr("data-inline").equals("true")) {
                styles.append(e.data());
                e.remove();
            }
        }
        return styles.toString();
    }
357957
function _classForDocument(doc) {
        switch (doc.getLanguage().getId()) {
        case "less":
        case "scss":
            return CSSPreprocessorDocument;
        case "css":
            return CSSDocument;
        case "javascript":
            return exports.config.experimental ? JSDocument : null;
        }

        if (LiveDevelopmentUtils.isHtmlFileExt(doc.file.fullPath)) {
            return HTMLDocument;
        }

        return null;
    }
360943
void setDocNames(List<Annotation> docs)
  {

    container = new IndexedContainer();

    container.addContainerProperty(PROP_DOC_NAME, String.class, "n/a");
    MetaColumns metaCols = generateMetaColumns();

    for (MetaDataCol metaDatum : metaCols.visibleColumns)
    {
      container.
        addContainerProperty(metaDatum.getColName(), String.class, "n/a");
    }

    for (MetaDataCol metaDatum : metaCols.sortColumns)
    {
      container.
        addContainerProperty(metaDatum.getColName(), String.class, "n/a");
    }

    container.addContainerProperty("corpus path", String.class, "n/a");
    container.addContainerProperty("info", Button.class, null);
    container.addContainerProperty("visualizer", Panel.class, null);

    for (Annotation a : docs)
    {
      String doc = a.getName();

      // reverse path and delete the brackets and set a new separator:
      // corpus > ... > subcorpus > document
      List<String> pathList = a.getAnnotationPath();
      if (pathList == null)
      {
        pathList = new LinkedList<>();
      }

      Collections.reverse(pathList);
      String path = StringUtils.join(pathList, " > ");

      // use corpus path for row id, since it should be unique by annis db schema
      Item row = container.addItem(path);
      if(row != null)
      {
        row.getItemProperty(PROP_DOC_NAME).setValue(doc);

        // add the metadata columns.
        for (MetaDataCol metaDataCol : metaCols.visibleColumns)
        {
          String value = generateCell(a.getAnnotationPath(), metaDataCol);
          row.getItemProperty(metaDataCol.getColName()).setValue(value);
        }

        for (MetaDataCol metaDataCol : metaCols.sortColumns)
        {
          if (!metaCols.visibleColumns.contains(metaDataCol))
          {
            // corpusName() holds the corpus path
            String value = generateCell(a.getAnnotationPath(), metaDataCol);
            row.getItemProperty(metaDataCol.getColName()).setValue(value);
          }
        }

        row.getItemProperty("corpus path").setValue(path);
        row.getItemProperty("visualizer").setValue(generateVisualizerLinks(doc));
        row.getItemProperty("info").setValue(generateInfoButtonCell(doc));
      }
    }
    setContainerDataSource(container);
    Object[] metaDataColNames = new Object[metaCols.visibleColumns.size()];

    for (int i = 0; i < metaDataColNames.length; i++)
    {
      metaDataColNames[i] = metaCols.visibleColumns.get(i).getColName();
    }

    Object[] columnNames = ArrayUtils.addAll(ArrayUtils.addAll(new Object[]
    {
      "document name"
    }, metaDataColNames), new Object[]
    {
      "corpus path", "visualizer", "info"
    });

    setVisibleColumns(columnNames);

    for (Object colName : columnNames)
    {
      setColumnHeader((String) colName, (String) colName);
    }

    sortByMetaData(metaCols.sortColumns);
  }