org.jdom2.Document Java Examples

The following examples show how to use org.jdom2.Document. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataMapper.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get all RUPs from the database that start after "from" and end before
 * "to". Allow for specifying a set of Yawl case Ids that are to be excluded
 * from the result. Also, it is possible to select only RUPs that are active.
 * 
 * @author jku, tbe
 * @param from
 * @param to
 * @param yCaseIdsToExclude
 * @param activeOnly
 * @return List<Case> all cases with RUPs that meet the selection criteria
 */
public List<Case> getRupsByInterval(Date from, Date to,
                                  List<String> yCaseIdsToExclude, boolean activeOnly) {

       if (yCaseIdsToExclude == null) yCaseIdsToExclude = new ArrayList<String>();
       List<Case> caseList = new ArrayList<Case>();
       for (Case c : getAllRups()) {
           if ((activeOnly && (! c.isActive())) || yCaseIdsToExclude.contains(c.getCaseId())) {
               continue;
           }
           Document rup = c.getRUP();
           long fromTime = getTime(rup, "//Activity/From");
           long toTime = getTime(rup, "//Activity/To");
           if ((fromTime > -1) && (toTime > -1) && (fromTime >= from.getTime()) && 
                   (toTime <= to.getTime())) {
               caseList.add(c);
           }
       }
       return caseList;
}
 
Example #2
Source File: MCRSwapInsertTargetTest.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testCloneInsertParam() throws JaxenException, JDOMException {
    String x = "mods:mods[mods:name[@type='personal']='p1'][mods:name[@type='personal'][2]='p2'][mods:name[@type='corporate']='c1']";
    Element template = new MCRNodeBuilder().buildElement(x, null, null);
    Document doc = new Document(template);
    MCRBinding root = new MCRBinding(doc);

    MCRRepeatBinding repeat = new MCRRepeatBinding("mods:mods/mods:name[@type='personal']", root, 2, 10, "clone");
    repeat.bindRepeatPosition();
    String insertParam = MCRInsertTarget.getInsertParameter(repeat);
    assertEquals("/mods:mods|1|clone|mods:name[(@type = \"personal\")]", insertParam);
    repeat.detach();

    new MCRInsertTarget().handle(insertParam, root);
    repeat = new MCRRepeatBinding("mods:mods/mods:name[@type='personal']", root, 1, 10, "build");
    assertEquals(3, repeat.getBoundNodes().size());
    assertEquals("p1", ((Element) (repeat.getBoundNodes().get(0))).getText());
    assertEquals("p1", ((Element) (repeat.getBoundNodes().get(1))).getText());
    assertEquals("name", ((Element) (repeat.getBoundNodes().get(1))).getName());
    assertEquals("personal", ((Element) (repeat.getBoundNodes().get(1))).getAttributeValue("type"));
    assertEquals("p2", ((Element) (repeat.getBoundNodes().get(2))).getText());
}
 
Example #3
Source File: CommandSnippetXmlParser.java    From gocd with Apache License 2.0 6 votes vote down vote up
public CommandSnippet parse(String xmlContent, String fileName, String relativeFilePath) {
    try {
        Document document = buildXmlDocument(xmlContent, CommandSnippet.class.getResource("command-snippet.xsd"));
        CommandSnippetComment comment = getComment(document);

        Element execTag = document.getRootElement();
        String commandName = execTag.getAttributeValue("command");
        List<String> arguments = new ArrayList<>();
        for (Object child : execTag.getChildren()) {
            Element element = (Element) child;
            arguments.add(element.getValue());
        }
        return new CommandSnippet(commandName, arguments, comment, fileName, relativeFilePath);
    } catch (Exception e) {
        String errorMessage = String.format("Reason: %s", e.getMessage());
        LOGGER.info("Could not load command '{}'. {}", fileName, errorMessage);
        return CommandSnippet.invalid(fileName, errorMessage, new EmptySnippetComment());
    }
}
 
Example #4
Source File: TestWSIFInvoker.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testGetQuote() {
        HashMap map = null;
        try {
            Document doc = _builder.build(new StringReader("<data><input>NAB.AX</input></data>"));
            map = WSIFInvoker.invokeMethod(
                    "http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl",
                    "", "getQuote",
                    doc.getRootElement(),
                    _authconfig);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        System.out.println("map = " + map);
        assertTrue(map.size() == 1);
        assertTrue(map.toString(), map.containsKey("Result"));
    }
 
Example #5
Source File: NameGenPanel.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void loadFromDocument(Document nameSet) throws DataConversionException
{
	Element generator = nameSet.getRootElement();
	java.util.List<?> rulesets = generator.getChildren("RULESET");
	java.util.List<?> lists = generator.getChildren("LIST");
	ListIterator<?> listIterator = lists.listIterator();

	while (listIterator.hasNext())
	{
		Element list = (Element) listIterator.next();
		loadList(list);
	}

	for (final Object ruleset : rulesets)
	{
		Element ruleSet = (Element) ruleset;
		RuleSet rs = loadRuleSet(ruleSet);
		allVars.addDataElement(rs);
	}
}
 
Example #6
Source File: MCRChangeTrackerTest.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testAddElement() throws JaxenException {
    Document doc = new Document(new MCRNodeBuilder().buildElement("document[title][title[2]]", null, null));
    MCRChangeTracker tracker = new MCRChangeTracker();

    Element title = new Element("title");
    doc.getRootElement().getChildren().add(1, title);
    assertEquals(3, doc.getRootElement().getChildren().size());
    assertTrue(doc.getRootElement().getChildren().contains(title));

    tracker.track(MCRAddedElement.added(title));
    tracker.undoChanges(doc);

    assertEquals(2, doc.getRootElement().getChildren().size());
    assertFalse(doc.getRootElement().getChildren().contains(title));
}
 
Example #7
Source File: TestParseXML.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testparseXML(){

        Document doc = JDOMUtil.fileToDocument("c:/temp/resourcing2.xml") ;
        Element resElem = doc.getRootElement();

        ResourceMap rMap = new ResourceMap("null") ;
        rMap.parse(resElem);

        String s = rMap.getOfferInteraction().toXML();
        System.out.println(s) ;

        s = rMap.getAllocateInteraction().toXML();
        System.out.println(s) ;

        s = rMap.getStartInteraction().toXML();
        System.out.println(s) ;

        s = rMap.getTaskPrivileges().toXML();
        System.out.println(s) ;
    }
 
Example #8
Source File: MCRChangeTrackerTest.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testSwapElements() throws JaxenException {
    Element root = new MCRNodeBuilder().buildElement("parent[name='a'][note][foo][name[2]='b'][note[2]]", null,
        null);
    Document doc = new Document(root);

    assertEquals("a", root.getChildren().get(0).getText());
    assertEquals("b", root.getChildren().get(3).getText());

    MCRChangeTracker tracker = new MCRChangeTracker();
    tracker.track(MCRSwapElements.swap(root, 0, 3));

    assertEquals("b", root.getChildren().get(0).getText());
    assertEquals("a", root.getChildren().get(3).getText());

    tracker.undoChanges(doc);

    assertEquals("a", root.getChildren().get(0).getText());
    assertEquals("b", root.getChildren().get(3).getText());
}
 
Example #9
Source File: MCRPIXPathMetadataService.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void insertIdentifier(MCRPersistentIdentifier identifier, MCRBase obj, String additional)
    throws MCRPersistentIdentifierException {
    String xpath = getProperties().get("Xpath");
    Document xml = obj.createXML();
    MCRNodeBuilder nb = new MCRNodeBuilder();
    try {
        nb.buildElement(xpath, identifier.asString(), xml);
        if (obj instanceof MCRObject) {
            final Element metadata = xml.getRootElement().getChild("metadata");
            ((MCRObject) obj).getMetadata().setFromDOM(metadata);
        } else {
            throw new MCRPersistentIdentifierException(obj.getId() + " is no MCRObject!",
                new OperationNotSupportedException(getClass().getName() + " only supports "
                    + MCRObject.class.getName() + "!"));
        }

    } catch (Exception e) {
        throw new MCRException("Error while inscribing PI to " + obj.getId(), e);

    }
}
 
Example #10
Source File: FeatureDatasetCapabilitiesWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static LatLonRect getSpatialExtent(Document doc) {
  Element root = doc.getRootElement();
  Element latlonBox = root.getChild("LatLonBox");
  if (latlonBox == null)
    return null;

  String westS = latlonBox.getChildText("west");
  String eastS = latlonBox.getChildText("east");
  String northS = latlonBox.getChildText("north");
  String southS = latlonBox.getChildText("south");
  if ((westS == null) || (eastS == null) || (northS == null) || (southS == null))
    return null;

  try {
    double west = Double.parseDouble(westS);
    double east = Double.parseDouble(eastS);
    double south = Double.parseDouble(southS);
    double north = Double.parseDouble(northS);
    return new LatLonRect(LatLonPoint.create(south, east), LatLonPoint.create(north, west));

  } catch (Exception e) {
    return null;
  }
}
 
Example #11
Source File: MCRXMLHelperTest.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void jsonSerialize() throws Exception {
    // simple text
    Element e = new Element("hallo").setText("Hallo Welt");
    JsonObject json = MCRXMLHelper.jsonSerialize(e);
    assertEquals("Hallo Welt", json.getAsJsonPrimitive("$text").getAsString());
    // attribute
    e = new Element("hallo").setAttribute("hallo", "welt");
    json = MCRXMLHelper.jsonSerialize(e);
    assertEquals("welt", json.getAsJsonPrimitive("_hallo").getAsString());

    // complex world class test
    URL world = MCRXMLHelperTest.class.getResource("/worldclass.xml");
    SAXBuilder builder = new SAXBuilder();
    Document worldDocument = builder.build(world.openStream());
    json = MCRXMLHelper.jsonSerialize(worldDocument.getRootElement());
    assertNotNull(json);
    assertEquals("World", json.getAsJsonPrimitive("_ID").getAsString());
    assertEquals("http://www.w3.org/2001/XMLSchema-instance", json.getAsJsonPrimitive("_xmlns:xsi").getAsString());
    JsonObject deLabel = json.getAsJsonArray("label").get(0).getAsJsonObject();
    assertEquals("de", deLabel.getAsJsonPrimitive("_xml:lang").getAsString());
    assertEquals("Staaten", deLabel.getAsJsonPrimitive("_text").getAsString());
    assertEquals(2, json.getAsJsonObject("categories").getAsJsonArray("category").size());
}
 
Example #12
Source File: XMLUtil.java    From PoseidonX with Apache License 2.0 6 votes vote down vote up
public static List readNodeStore(InputStream in) {
    List<Element> returnElement=new LinkedList<Element>();
    try {
        boolean validate = false;
        SAXBuilder builder = new SAXBuilder(validate);
        Document doc = builder.build(in);
        Element root = doc.getRootElement();
        // 获取根节点 <university>
        for(Element  element: root.getChildren()){
            List<Element> childElement= element.getChildren();
            for(Element tmpele:childElement){
                returnElement.add(tmpele);
            }

        }
        return returnElement;
        //readNode(root, "");
    } catch (Exception e) {
        LOGGER.error(e.getMessage(),e);
    }
    return returnElement;
}
 
Example #13
Source File: MCRClassificationEditorResourceTest.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void saveClassiWithSub() throws Exception {
    SAXBuilder saxBuilder = new SAXBuilder();
    Document doc = saxBuilder.build(getClass().getResourceAsStream("/classi/classiEditor_ClassiSub.xml"));
    String json = doc.getRootElement().getText();
    Response response = target("/classifications/save").request().post(Entity.json(json));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
}
 
Example #14
Source File: XMLUtil.java    From PoseidonX with Apache License 2.0 5 votes vote down vote up
public static void writeNodeToFile(File destFile,JarOutputStream zos) {
        boolean validate = false;
        try {
            InputStream in = new FileInputStream(destFile);
            SAXBuilder builder = new SAXBuilder(validate);
            Document doc = builder.build(in);
            // 获取根节点 <university>
            Element root = doc.getRootElement();
            List<Element> list=root.getChildren();
            for(Element ele:list){
                for(Element addele:storeElement){
                    ele.addContent(addele.detach());
                }

            }
            XMLOutputter out = new XMLOutputter();
          //  SAXOutput
         //   FileOutputStream fos = new FileOutputStream(destFile);
            out.output(doc, zos);
//            in=null;
//            in = new FileInputStream(destFile);
//            int len;
//            byte[] buf = new byte[2048];
//            while ((len = in.read(buf)) >= 0) {
//                zos.write(buf, 0, len);
//
//            }
            zos.closeEntry();
            in.close();
        }  catch (Exception e) {
            LOGGER.error(e.getMessage(),e);
        }

    }
 
Example #15
Source File: DirectoryEntryListTest.java    From emissary with Apache License 2.0 5 votes vote down vote up
@Test
public void testXml() throws JDOMException {
    final Document jdom = JDOMUtil.createDocument("<entryList></entryList>", false);
    final Element root = jdom.getRootElement();
    root.addContent(this.d.getXML());
    root.addContent(this.d2.getXML());

    final DirectoryEntryList dl2 = DirectoryEntryList.fromXML(root);
    assertNotNull("From xml", dl2);
    assertEquals("Size from xml", 2, dl2.size());
}
 
Example #16
Source File: EventRuleModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static EventRuleModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    final EventRuleContext ruleContext = new EventRuleContext();
    final EventRuleParser ruleParser = new EventRuleParser(context, ruleContext);

    for(Element regionRootElement : XMLUtils.getChildren(doc.getRootElement(), "filters", "regions")) {
        for(Element applyEl : regionRootElement.getChildren("apply")) {
            ruleParser.parse(applyEl);
        }
    }

    return new EventRuleModule(ruleContext);
}
 
Example #17
Source File: KitModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public KitModule parse(MapFactory factory, Logger logger, Document doc)
    throws InvalidXMLException {
  for (Element kitsElement : doc.getRootElement().getChildren("kits")) {
    for (Element kitElement : kitsElement.getChildren("kit")) {
      factory.getKits().parse(kitElement);
    }
  }
  return new KitModule();
}
 
Example #18
Source File: MCRMetsSave.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates the mets.xml belonging to the given derivate. Removes the file
 * from the mets document (updates file sections and stuff within the
 * mets.xml)
 *
 * @param file
 *            a handle for the file to add to the mets.xml
 */
public static void updateMetsOnFileDelete(MCRPath file) throws JDOMException, SAXException, IOException {
    MCRObjectID derivateID = MCRObjectID.getInstance(file.getOwner());
    Document mets = getCurrentMets(derivateID.toString());
    if (mets == null) {
        LOGGER.info("Derivate with id \"{}\" has no mets file. Nothing to do", derivateID);
        return;
    }
    mets = MCRMetsSave.updateOnFileDelete(mets, file);
    if (mets != null) {
        MCRMetsSave.saveMets(mets, derivateID);
    }
}
 
Example #19
Source File: AbstractRDFToDMNTransformerTest.java    From jdmn with Apache License 2.0 5 votes vote down vote up
private void sort(Document document) {
    Comparator<Element> comparator = new DMNNodeComparator();

    // Sort definitions
    Element rootElement = document.getRootElement();
    if (rootElement != null) {
        rootElement.sortChildren(comparator);

        // Sort decision
        Element decision = rootElement.getChild("decision", Namespace.getNamespace("dmn", DMN_11.getNamespace()));
        if (decision != null) {
            decision.sortChildren(comparator);
        }
    }
}
 
Example #20
Source File: MCRDataciteClient.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
private static byte[] documentToByteArray(Document document) throws IOException {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
    xout.output(document, outputStream);

    return outputStream.toByteArray();
}
 
Example #21
Source File: MCRBatchEditorCommands.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
public static void edit(String oid, String level, Action a, String field1, String value1, String field2,
    String value2)
    throws JaxenException, MCRPersistenceException, MCRAccessException, IOException {
    Document xmlOld = getObjectXML(oid);
    Document xmlNew = xmlOld.clone();

    for (Element base : getlevelElements(xmlNew, level)) {
        if (a == Action.ADD) {
            add(base, field1, value1);
        } else if (a == Action.REMOVE) {
            find(base, field1, value1).forEach(e -> e.detach());
        } else if (a == Action.REPLACE) {
            List<Element> found = find(base, field1, value1);
            found.forEach(e -> e.detach());
            if (!found.isEmpty()) {
                add(base, field2, value2);
            }
        } else if (a == Action.ADD_IF) {
            if (!find(base, field1, value1).isEmpty()) {
                add(base, field2, value2);
            }
        } else if (a == Action.REMOVE_IF) {
            if (!find(base, field1, value1).isEmpty()) {
                find(base, field2, value2).forEach(e -> e.detach());
            }
        }
    }

    saveIfModified(xmlOld, xmlNew);
}
 
Example #22
Source File: ResupplyConfig.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param resupplyDoc DOM document for resupply configuration.
 * @param partPackageConfig the part package configuration.
 */
public ResupplyConfig(Document resupplyDoc,
        PartPackageConfig partPackageConfig) {

	// Initialize amountResourceConfig in this constructor
	ResourceUtil.getInstance().initializeNewSim();

    resupplyTemplates = new ArrayList<ResupplyTemplate>();
    loadResupplyTemplates(resupplyDoc, partPackageConfig);
}
 
Example #23
Source File: WmsViewer.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean getCapabilities() {

    Formatter f = new Formatter();
    if (endpoint.indexOf("?") > 0) {
      f.format("%s&request=GetCapabilities&service=WMS&version=%s", endpoint, version);
    } else {
      f.format("%s?request=GetCapabilities&service=WMS&version=%s", endpoint, version);
    }
    System.out.printf("getCapabilities request = '%s'%n", f);
    String url = f.toString();
    info = new Formatter();
    info.format("%s%n", url);

    try (HTTPSession session = HTTPFactory.newSession(url); HTTPMethod method = HTTPFactory.Get(session, url)) {
      int statusCode = method.execute();

      info.format(" Status = %d %s%n", method.getStatusCode(), method.getStatusText());
      info.format(" Status Line = %s%n", method.getStatusLine());
      printHeaders(" Response Headers", method.getResponseHeaders().entries());
      info.format("GetCapabilities:%n%n");

      if (statusCode == 404) {
        throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine());
      }
      if (statusCode >= 300) {
        throw new IOException(method.getPath() + " " + method.getStatusLine());
      }

      SAXBuilder builder = new SAXBuilder();
      Document tdoc = builder.build(method.getResponseAsStream());
      Element root = tdoc.getRootElement();
      parseGetCapabilities(root);
    } catch (Exception e) {
      info.format("%s%n", e.getMessage());
      JOptionPane.showMessageDialog(this, "Failed " + e.getMessage());
      return false;
    }

    return true;
  }
 
Example #24
Source File: MCRRealmResolver.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
private Element getElement(final String id) {
    Document realmsDocument = MCRRealmFactory.getRealmsDocument();
    List<Element> realms = realmsDocument.getRootElement().getChildren("realm");
    return realms.stream()
        .filter(realm -> id.equals(realm.getAttributeValue("id")))
        .findAny()
        .orElse(null);
}
 
Example #25
Source File: XsdTypeProvider.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
private void parseEdfiSchema(Resource schemaFile, SAXBuilder b) throws JDOMException, IOException {
    Document doc = b.build(schemaFile.getURL());

    for (Element xsInclude : doc.getDescendants(Filters.element(INCLUDE, XS_NAMESPACE))) {
        String inclSchemaLocation = xsInclude.getAttributeValue(SCHEMA_LOCATION);
        parseEdfiSchema(schemaFile.createRelative(inclSchemaLocation), b);
    }

    parseComplexTypes(doc);
}
 
Example #26
Source File: RSS20YahooParser.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * Indicates if a JDom document is an RSS instance that can be parsed with the parser.
 * <p/>
 * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and RSS
 * ("http://purl.org/rss/1.0/") namespaces being defined in the root element.
 *
 * @param document document to check if it can be parsed with this parser implementation.
 * @return <b>true</b> if the document is RSS1., <b>false</b> otherwise.
 */
@Override
public boolean isMyType(final Document document) {
    boolean ok = false;

    final Element rssRoot = document.getRootElement();
    final Namespace defaultNS = rssRoot.getNamespace();

    ok = defaultNS != null && defaultNS.equals(getRSSNamespace());

    return ok;
}
 
Example #27
Source File: YNetRunner.java    From yawl with GNU Lesser General Public License v3.0 5 votes vote down vote up
private synchronized void processCompletedSubnet(YPersistenceManager pmgr,
                                                 YIdentifier caseIDForSubnet,
                                                 YCompositeTask busyCompositeTask,
                                                 Document rawSubnetData)
        throws YDataStateException, YStateException, YQueryException,
        YPersistenceException {

    _logger.debug("--> processCompletedSubnet");

    if (caseIDForSubnet == null) throw new RuntimeException();

    if (busyCompositeTask.t_complete(pmgr, caseIDForSubnet, rawSubnetData)) {
        _busyTasks.remove(busyCompositeTask);
        if (pmgr != null) pmgr.updateObject(this);
        logCompletingTask(caseIDForSubnet, busyCompositeTask);

        //check to see if completing this task resulted in completing the net.
        if (endOfNetReached()) {
            if (_containingCompositeTask != null) {
                YNetRunner parentRunner = _engine.getNetRunner(_caseIDForNet.getParent());
                if ((parentRunner != null) && _containingCompositeTask.t_isBusy()) {
                    parentRunner.setEngine(_engine);           // added to avoid NPE
                    Document dataDoc = _net.usesSimpleRootData() ?
                                _net.getInternalDataDocument() :
                                _net.getOutputData() ;
                    parentRunner.processCompletedSubnet(pmgr, _caseIDForNet,
                                _containingCompositeTask, dataDoc);
                }
            }
        }
        kick(pmgr);
    }
    _logger.debug("<-- processCompletedSubnet");
}
 
Example #28
Source File: FeatureDatasetCapabilitiesWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static String getAltUnits(Document doc) {
  Element root = doc.getRootElement();
  String altUnits = root.getChildText("AltitudeUnits");
  if (altUnits == null || altUnits.isEmpty())
    return null;
  return altUnits;
}
 
Example #29
Source File: PlayableRegionModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static PlayableRegionModule parse(MapModuleContext context, Logger log, Document doc) throws InvalidXMLException {
    Element playableRegionElement = doc.getRootElement().getChild("playable");
    if(playableRegionElement != null) {
        return new PlayableRegionModule(context.needModule(RegionParser.class).property(playableRegionElement).legacy().union());
    }
    return null;
}
 
Example #30
Source File: DescribeCoverage.java    From tds with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
Document generateDescribeCoverageDoc() {
  // CoverageDescription (wcs) [1]
  Element coverageDescriptionsElem = new Element("CoverageDescription", wcsNS);
  coverageDescriptionsElem.addNamespaceDeclaration(gmlNS);
  coverageDescriptionsElem.addNamespaceDeclaration(xlinkNS);
  coverageDescriptionsElem.setAttribute("version", this.getVersion());
  // ToDo Consider dealing with "updateSequence"
  // coverageDescriptionsElem.setAttribute( "updateSequence", this.getCurrentUpdateSequence() );

  for (String curCoverageId : this.coverages)
    coverageDescriptionsElem.addContent(genCoverageOfferingElem(curCoverageId));

  return new Document(coverageDescriptionsElem);
}