Package nu.xom

Examples of nu.xom.Elements


   *
   * @param elem The XML Element that contains the trained rescorer model.
   * @throws Exception
   */
  public void readElement(Element elem) throws Exception {
    Elements maxents = elem.getChildElements("maxent");
    modelsByType = new HashMap<String,GISModel>();
    for(int i=0;i<maxents.size();i++) {
      Element maxent = maxents.get(i);
      String type = maxent.getAttributeValue("type");
      StringGISModelReader sgmr = new StringGISModelReader(maxent.getValue());
      GISModel gm = sgmr.getModel();
      modelsByType.put(type, gm);
    }   
View Full Code Here


   * within a dataSection.
   *
   * @param safDoc The SAF XML document to be altered.
   */
  public static void discard(Document safDoc) {
    Elements elements = safDoc.getRootElement().getChildElements();
    XPointComparator xpc = new XPointComparator();
    List<String> xpoints = new ArrayList<String>();
    Set<String> dataStarts = new HashSet<String>();
    Set<String> dataStops = new HashSet<String>();
    Map<String,List<Element>> elementsByXPoints = new HashMap<String,List<Element>>();
    for(int i=0;i<elements.size();i++) {
      Element e = elements.get(i);
      String from = e.getAttributeValue("from");
      String to = e.getAttributeValue("to");
      xpoints.add(from);
      xpoints.add(to);
      if(SafTools.getSlotValue(e, "type").equals("dataSection")) {
View Full Code Here

        }
        regex = rParser.getNodeText(elem.getChildElements("regexp").get(0));
        int pg = Integer.parseInt(elem.getChildElements("regexp").get(0).getAttributeValue("parsegroup"));
        RPNode RPchild = new RPNode(regex, pg, type, id, value, unique, safFlag, rParser);
        Elements childElems = elem.getChildElements("child");
        for(int i=0;i<childElems.size();i++) {
          Element child = childElems.get(i);
          String childType = child.getAttributeValue("type");
          String childId = child.getAttributeValue("id");
          // find the <node> the <child> refers to
          Element node2 = (Element)rParser.findNode(childType, childId);
          if(node2==null)
View Full Code Here

        if(defElem.getAttributeValue("type").equals("const")) {
            retval.append(getNodeText(defElem));
        } else if(defElem.getAttributeValue("type").equals("list")) {
            retval.append("(");
            int i = 0;
            Elements items = defElem.getChildElements("item");
            for(int j=0;j<items.size();j++) {
                if(i>0) {
                    retval.append("|");
                }
                retval.append(getNodeText(items.get(j)));
                i++;
            }
            retval.append(")");
        }
        nodeDict.put(idref, retval.toString());
View Full Code Here

      Element component = getChild(MetacardInfo.getName(version));
      if (component != null) {
        _metacardInfo = new MetacardInfo(component);
      }
      // Resource Set
      Elements components = element.getChildElements(Identifier.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _identifiers.add(new Identifier(components.get(i)));
      components = element.getChildElements(Title.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _titles.add(new Title(components.get(i)));
      components = element.getChildElements(Subtitle.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _subtitles.add(new Subtitle(components.get(i)));
      component = getChild(Description.getName(version));
      if (component != null)
        _description = new Description(component);
      components = element.getChildElements(Language.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _languages.add(new Language(components.get(i)));
      component = getChild(Dates.getName(version));
      if (component != null)
        _dates = new Dates(component);
      component = getChild(Rights.getName(version));
      if (component != null)
        _rights = new Rights(component);
      components = element.getChildElements(Source.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _sources.add(new Source(components.get(i)));
      components = element.getChildElements(Type.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _types.add(new Type(components.get(i)));
      components = element.getChildElements(Creator.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _creators.add(new Creator(components.get(i)));
      components = element.getChildElements(Publisher.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _publishers.add(new Publisher(components.get(i)));
      components = element.getChildElements(Contributor.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _contributors.add(new Contributor(components.get(i)));
      components = element.getChildElements(PointOfContact.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _pointOfContacts.add(new PointOfContact(components.get(i)));

      // Format Set
      component = getChild(Format.getName(version));
      if (component != null)
        _format = new Format(component);

      // Summary Set
      components = element.getChildElements(SubjectCoverage.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _subjectCoverages.add(new SubjectCoverage(components.get(i)));
      components = element.getChildElements(VirtualCoverage.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _virtualCoverages.add(new VirtualCoverage(components.get(i)));
      components = element.getChildElements(TemporalCoverage.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        _temporalCoverages.add(new TemporalCoverage(components.get(i)));
      components = element.getChildElements(GeospatialCoverage.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        geospatialCoverages.add(new GeospatialCoverage(components.get(i)));
      components = element.getChildElements(RelatedResource.getName(version), namespace);
      for (int i = 0; i < components.size(); i++)
        loadRelatedResource(components.get(i));

      // Resource Set again
      component = getChild(ResourceManagement.getName(version));
      if (component != null)
        _resourceManagement = new ResourceManagement(component);

      // Security Set
      component = getChild(Security.getName(version));
      if (component != null) {
        _security = new Security(component);

        // Extensible Layer

        // We use the security component to locate the extensible layer. If it is null, this resource is going
        // to fail validation anyhow (or we're in DDMS 5.0, which doesn't have an extensible layer, so we skip
        // the extensible layer.
        int index = 0;
        Elements allElements = element.getChildElements();
        while (allElements.get(index) != component) {
          index++;
        }
        for (int i = index + 1; i < allElements.size(); i++)
          _extensibleElements.add(new ExtensibleElement(allElements.get(i)));
      }
      populatedOrderedList();
      validate();
    }
    catch (InvalidDDMSException e) {
View Full Code Here

   * must be mediated into a separate RelatedResource instance.
   *
   * @param resource the top-level element
   */
  private void loadRelatedResource(Element resource) throws InvalidDDMSException {
    Elements children = resource.getChildElements(RelatedResource.OLD_INNER_NAME, getNamespace());
    if (children.size() <= 1) {
      _relatedResources.add(new RelatedResource(resource));
    }
    else {
      for (int i = 0; i < children.size(); i++) {
        Element copy = new Element(resource);
        copy.removeChildren();
        copy.appendChild(new Element(children.get(i)));
        _relatedResources.add(new RelatedResource(copy));
      }
    }
  }
View Full Code Here

   */
  public Notice(Element element) throws InvalidDDMSException {
    try {
      setXOMElement(element, false);
      _noticeTexts = new ArrayList<NoticeText>();
      Elements noticeTexts = element.getChildElements(NoticeText.getName(getDDMSVersion()),
        getDDMSVersion().getIsmNamespace());
      for (int i = 0; i < noticeTexts.size(); i++) {
        _noticeTexts.add(new NoticeText(noticeTexts.get(i)));
      }
      _noticeAttributes = new NoticeAttributes(element);
      _securityAttributes = new SecurityAttributes(element);
      validate();
    }
View Full Code Here

   * @throws InvalidDDMSException if any required information is missing or malformed
   */
  public ProfileList(Element element) throws InvalidDDMSException {
    try {
      setXOMElement(element, false);
      Elements values = element.getChildElements(Profile.getName(getDDMSVersion()), getNamespace());
      _profiles = new ArrayList<Profile>();
      for (int i = 0; i < values.size(); i++) {
        _profiles.add(new Profile(values.get(i)));
      }
      _securityAttributes = new SecurityAttributes(element);
      validate();
    }
    catch (InvalidDDMSException e) {
View Full Code Here

   * @throws InvalidDDMSException if any required information is missing or malformed
   */
  public Group(Element element) throws InvalidDDMSException {
    super(element);
    try {
      Elements values = element.getChildElements(GroupValue.getName(getDDMSVersion()), getNamespace());
      _groupValues = new ArrayList<GroupValue>();
      for (int i = 0; i < values.size(); i++) {
        _groupValues.add(new GroupValue(values.get(i)));
      }
      validate();
    }
    catch (InvalidDDMSException e) {
      e.setLocator(getQualifiedName());
View Full Code Here

   */
  public Organization(Element element) throws InvalidDDMSException {
    super(element, false);
    try {
      String namespace = element.getNamespaceURI();
      Elements components = element.getChildElements(SubOrganization.getName(getDDMSVersion()), namespace);
      _subOrganizations = new ArrayList<SubOrganization>();
      for (int i = 0; i < components.size(); i++)
        _subOrganizations.add(new SubOrganization(components.get(i)));
      validate();
    }
    catch (InvalidDDMSException e) {
      e.setLocator(getQualifiedName());
      throw (e);
View Full Code Here

TOP

Related Classes of nu.xom.Elements

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.