List of usage examples for org.jdom2 Namespace getPrefix
public String getPrefix()
Namespace
. From source file:de.dfki.iui.mmds.core.emf.persistence.EmfPersistence.java
License:Creative Commons License
/** * Serialize an object to XML using standard EMF * /*w w w.j a va2s . co m*/ * @param object * @return * @throws Exception */ private static Document createDocFromEObject(EObject object, Map<String, Namespace> namespaces) throws Exception { HashMap<String, Object> options = new HashMap<String, Object>(); options.put(XMIResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.FALSE); options.put(XMIResource.OPTION_DECLARE_XML, Boolean.FALSE); options.put(XMLResource.OPTION_FORMATTED, Boolean.FALSE); options.put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE); String result = writeToString(object, NonContainmentReferenceHandling.KEEP_ORIGINAL_LOCATION, options); Document doc = null; try { doc = new SAXBuilder().build(new StringReader(result)); Namespace namespace = doc.getRootElement().getNamespace(); if (!namespaces.containsKey(namespace.getPrefix())) namespaces.put(namespace.getPrefix(), namespace); for (Namespace additionalNamespace : doc.getRootElement().getAdditionalNamespaces()) { if (!namespaces.containsKey(additionalNamespace.getPrefix())) namespaces.put(additionalNamespace.getPrefix(), additionalNamespace); } } catch (Exception e) { logger.error(e.getMessage()); assert (false); } return doc; }
From source file:edu.pitt.apollo.runmanagerservice.methods.stage.StageExperimentMethod.java
License:Apache License
@Override public void runApolloService() { XMLSerializer serializer = new XMLSerializer(); XMLDeserializer deserializer = new XMLDeserializer(); InfectiousDiseaseScenario baseScenario = idtes.getInfectiousDiseaseScenarioWithoutIntervention(); // clear all set control strategies in base baseScenario.getInfectiousDiseaseControlStrategies().clear(); List<SoftwareIdentification> modelIds = idtes.getInfectiousDiseaseTransmissionModelIds(); try {//from w w w . j ava2 s . c o m DataServiceAccessor dataServiceAccessor = new DataServiceAccessor(); for (SoftwareIdentification modelId : modelIds) { // create a base scenario copy String baseXml = serializer.serializeObject(baseScenario); InfectiousDiseaseScenario baseScenarioCopy = deserializer.getObjectFromMessage(baseXml, InfectiousDiseaseScenario.class); for (InfectiousDiseaseControlStrategy strategy : idtes.getInfectiousDiseaseControlStrategies()) { for (InfectiousDiseaseControlMeasure controlMeasure : strategy.getControlMeasures()) { baseScenarioCopy.getInfectiousDiseaseControlStrategies().add(controlMeasure); } } List<SensitivityAnalysisSpecification> sensitivityAnalyses = idtes.getSensitivityAnalyses(); for (SensitivityAnalysisSpecification sensitivityAnalysis : sensitivityAnalyses) { if (sensitivityAnalysis instanceof OneWaySensitivityAnalysisOfContinousVariableSpecification) { OneWaySensitivityAnalysisOfContinousVariableSpecification owsaocv = (OneWaySensitivityAnalysisOfContinousVariableSpecification) sensitivityAnalysis; double min = owsaocv.getMinimumValue(); double max = owsaocv.getMaximumValue(); double increment = (max - min) / owsaocv.getNumberOfDiscretizations().intValueExact(); String scenarioXML = serializer.serializeObject(baseScenarioCopy); double val = min; while (val <= max) { String param = owsaocv.getUniqueApolloLabelOfParameter(); Document jdomDocument; SAXBuilder jdomBuilder = new SAXBuilder(); try { jdomDocument = jdomBuilder.build( new ByteArrayInputStream(scenarioXML.getBytes(StandardCharsets.UTF_8))); } catch (JDOMException | IOException ex) { ErrorUtils.reportError(runId, "Error inserting experiment run. Error was " + ex.getMessage(), authentication); return; } Element e = jdomDocument.getRootElement(); List<Namespace> namespaces = e.getNamespacesInScope(); for (Namespace namespace : namespaces) { if (namespace.getURI().contains("http://types.apollo.pitt.edu")) { param = param.replaceAll("/", "/" + namespace.getPrefix() + ":"); param = param.replaceAll("\\[", "\\[" + namespace.getPrefix() + ":"); break; } } XPathFactory xpf = XPathFactory.instance(); XPathExpression<Element> expr; expr = xpf.compile(param, Filters.element(), null, namespaces); List<Element> elements = expr.evaluate(jdomDocument); for (Element element : elements) { element.setText(Double.toString(val)); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLOutputter xmlOutputter = new XMLOutputter(); xmlOutputter.output(jdomDocument, baos); InfectiousDiseaseScenario newScenario = deserializer.getObjectFromMessage( new String(baos.toByteArray()), InfectiousDiseaseScenario.class); // new scenario is ready to be staged RunSimulationMessage runSimulationMessage = new RunSimulationMessage(); runSimulationMessage.setAuthentication(authentication); runSimulationMessage .setSimulatorTimeSpecification(message.getSimulatorTimeSpecification()); runSimulationMessage.setSoftwareIdentification(modelId); runSimulationMessage.setInfectiousDiseaseScenario(newScenario); StageMethod stageMethod = new StageMethod(runSimulationMessage, runId); InsertRunResult result = stageMethod.stage(); BigInteger newRunId = result.getRunId(); MethodCallStatus status = dataServiceAccessor.getRunStatus(newRunId, authentication); if (status.getStatus().equals(MethodCallStatusEnum.FAILED)) { ErrorUtils.reportError(runId, "Error inserting run in experiment with run ID " + runId + "" + ". Error was for inserting ID " + newRunId + " with message " + status.getMessage(), authentication); return; } val += increment; } } } } dataServiceAccessor.updateStatusOfRun(runId, MethodCallStatusEnum.TRANSLATION_COMPLETED, "All runs for this experiment have been translated", authentication); } catch (DeserializationException | IOException | SerializationException | RunManagementException ex) { ErrorUtils.reportError(runId, "Error inserting experiment run. Error was " + ex.getMessage(), authentication); return; } }
From source file:es.upm.dit.xsdinferencer.extraction.extractorImpl.TypesExtractorImpl.java
License:Apache License
/** * This method traverses all the elements of each input document in order to find all the namespace URI to prefix mappings present at the documents. * With that information, the map between namespace URIs and their known prefixes is filled. It is used later to solve which prefix should be bound * to each namespace URI.//from w w w .j a va 2s . co m */ private void fillKnownNamespaceToPrefixMappings() { Filter<Element> elementFilter = Filters.element(); for (int i = 0; i < xmlDocuments.size(); i++) { for (Element element : xmlDocuments.get(i).getDescendants(elementFilter)) { for (Namespace namespace : element.getNamespacesInScope()) { //We do not add XSI to the known namespaces if (namespace.getURI().equalsIgnoreCase(XSI_NAMESPACE_URI)) continue; String uri = namespace.getURI(); String prefix = namespace.getPrefix(); SortedSet<String> currentPrefixes = prefixNamespaceMapping.get(uri); if (currentPrefixes == null) { currentPrefixes = new TreeSet<String>(); prefixNamespaceMapping.put(uri, currentPrefixes); } currentPrefixes.add(prefix); } //If the element belongs to the empty namespace (empty string) with no prefix, we must add //this to the prefix-namespace mapping explicitly if (element.getNamespacePrefix().equals("") && element.getNamespaceURI().equals("")) { String uri = ""; String prefix = ""; SortedSet<String> currentPrefixes = prefixNamespaceMapping.get(uri); if (currentPrefixes == null) { currentPrefixes = new TreeSet<>(); prefixNamespaceMapping.put(uri, currentPrefixes); } currentPrefixes.add(prefix); } } } }
From source file:net.exclaimindustries.paste.braket.server.TeamDownloader.java
License:Open Source License
public static Team parseTeam(Document document) throws MalformedURLException { // Parse out the details Element rootNode = document.getRootElement(); // I need the espn namespace List<Namespace> namespaceList = rootNode.getNamespacesInScope(); Namespace ns = Namespace.NO_NAMESPACE; for (Namespace namespace : namespaceList) { if (namespace.getPrefix() == "espn") { ns = namespace;/* w w w.java 2s . c o m*/ break; } } // Find the "item" element that has the right stuff in it Element channel = rootNode.getChild("channel"); List<Element> items = channel.getChildren("item"); Element teamElement = null; for (Element item : items) { if (item.getChild("teamAbbrev", ns) != null) { teamElement = item.clone(); break; } } if (teamElement == null) { // Couldn't find any info about the team, so skip it. return null; } // Make sure that the given ID matches the ID in the team (else this // is not a real team) Long teamId = Long.valueOf(teamElement.getChildText("teamId", ns)); Team team = new Team(); team.setId(teamId); String abbreviation = digOutCDATA(teamElement, "teamAbbrev", ns); String displayName = digOutCDATA(teamElement, "teamDisplayName", ns); String location = digOutCDATA(teamElement, "teamLocation", ns); String nickname = digOutCDATA(teamElement, "teamNickname", ns); String teamNameString = teamElement.getChildText("teamName", ns); String teamColorString = "#" + teamElement.getChildText("teamColor", ns); String teamLogoUrl = teamElement.getChildText("teamLogo", ns); TeamName teamName = new TeamName(location, teamNameString, displayName, nickname, abbreviation); team.setName(teamName); try { if (teamColorString != null) { RGBAColor color = RGBAColor.fromCSSString(teamColorString); team.setColor(color); } } catch (Exception e) { // TODO Is this okay? } // Save the image name (should be the same as the downloaded version) URL url = new URL(teamLogoUrl); File file = new File(url.getPath()); String teamLogoName = file.getName(); team.setPicture(teamLogoName); return team; }
From source file:org.apache.maven.io.util.WriterUtils.java
License:Apache License
/** * Method replaceXpp3DOM.//from www . j a va 2s . co m * * @param parent * @param counter * @param parentDom */ public static void replaceXpp3DOM(final Element parent, final Xpp3Dom parentDom, final IndentationCounter counter) { if (parentDom.getChildCount() > 0) { final Xpp3Dom[] childs = parentDom.getChildren(); final Collection domChilds = new ArrayList(); for (final Xpp3Dom child : childs) { domChilds.add(child); } final ListIterator it = parent.getChildren().listIterator(); while (it.hasNext()) { final Element elem = (Element) it.next(); final Iterator it2 = domChilds.iterator(); Xpp3Dom corrDom = null; while (it2.hasNext()) { final Xpp3Dom dm = (Xpp3Dom) it2.next(); if (dm.getName().equals(elem.getName())) { corrDom = dm; break; } } if (corrDom != null) { domChilds.remove(corrDom); replaceXpp3DOM(elem, corrDom, new IndentationCounter(counter.getDepth() + 1)); counter.increaseCount(); } else { it.remove(); } } final Iterator it2 = domChilds.iterator(); while (it2.hasNext()) { final Xpp3Dom dm = (Xpp3Dom) it2.next(); final String rawName = dm.getName(); final String[] parts = rawName.split(":"); Element elem; if (parts.length > 1) { final String nsId = parts[0]; String nsUrl = dm.getAttribute("xmlns:" + nsId); final String name = parts[1]; if (nsUrl == null) { nsUrl = parentDom.getAttribute("xmlns:" + nsId); } elem = factory.element(name, Namespace.getNamespace(nsId, nsUrl)); } else { Namespace root = parent.getNamespace(); for (Namespace n : parent.getNamespacesInherited()) { if (n.getPrefix() == null || n.getPrefix().length() == 0) { root = n; break; } } elem = factory.element(dm.getName(), root); } final String[] attributeNames = dm.getAttributeNames(); for (final String attrName : attributeNames) { if (attrName.startsWith("xmlns:")) { continue; } elem.setAttribute(attrName, dm.getAttribute(attrName)); } insertAtPreferredLocation(parent, elem, counter); counter.increaseCount(); replaceXpp3DOM(elem, dm, new IndentationCounter(counter.getDepth() + 1)); } } else if (parentDom.getValue() != null) { List<Content> cl = parent.getContent(); boolean foundCdata = false; for (Content c : cl) { if (c instanceof CDATA) { foundCdata = true; } } if (!foundCdata) { parent.setText(parentDom.getValue()); } } }
From source file:org.cloudsimulator.xml.rdf.xmlrdfconverter.BusinessConfigurationToXmlRdf.java
License:Open Source License
public static Element createBusinessConfigurationElement(final Namespace nameSpace, final Document documentParent, final BusinessConfiguration businessConfiguration, final String uriBusinessConfiguration) { Element businessConfigurationElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":BusinessConfiguration"); businessConfigurationElement.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":about", uriBusinessConfiguration); businessConfigurationElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasName", businessConfiguration.getHasName())); businessConfigurationElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasIdentifier", businessConfiguration.getHasIdentifier())); businessConfigurationElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasContractId", businessConfiguration.getHasContractId())); for (User creator : businessConfiguration.getCreatorList()) { if (creator != null) { businessConfigurationElement.appendChild( XmlUtility.createResourceElement(nameSpace, documentParent, "createdBy", creator.getUri())); }/* ww w . j a va 2 s.c om*/ } boolean firstIcaroApplicationOrTenant = true; Element hasPartElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasPart"); for (IcaroApplication icaroApplication : businessConfiguration.getIcaroApplicationList()) { if (icaroApplication != null) { if (firstIcaroApplicationOrTenant) { businessConfigurationElement.appendChild(hasPartElement); firstIcaroApplicationOrTenant = false; } Element icaroApplicationElement = IcaroApplicationToXmlRdf.createIcaroApplicationElement(nameSpace, documentParent, icaroApplication, IcaroApplication.getPathUri() + icaroApplication.getTypeRdf().replace("&app;", "") + ":" + businessConfiguration.getLocalUri() + "_" + businessConfiguration.getIcaroApplicationList().indexOf(icaroApplication)); hasPartElement.appendChild(icaroApplicationElement); } } for (IcaroTenant icaroTenant : businessConfiguration.getIcaroTenantList()) { if (icaroTenant != null) { if (firstIcaroApplicationOrTenant) { businessConfigurationElement.appendChild(hasPartElement); firstIcaroApplicationOrTenant = false; } Element icaroTenantElement = IcaroTenantToXmlRdf.createIcaroTenantElement(nameSpace, documentParent, icaroTenant, IcaroTenant.getPathUri() + "Tenant:" + businessConfiguration.getLocalUri() + "_" + businessConfiguration.getIcaroTenantList().indexOf(icaroTenant)); // Element icaroTenantElement = // IcaroTenantToXmlRdf.createIcaroTenantElement(nameSpace, // documentParent, icaroTenant, IcaroTenant.getPathUri() // + // icaroTenant.getIsTenantOf().substring(IcaroApplication.getPathUri().length(), // icaroTenant.getIsTenantOf().lastIndexOf(":")) + "Tenant:" + // businessConfiguration.getLocalUri() + "_" // + // businessConfiguration.getIcaroTenantList().indexOf(icaroTenant)); hasPartElement.appendChild(icaroTenantElement); // TODO Correggere } } boolean firstSlAgreement = true; Element hasSLAElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasSLA"); for (SLAgreement slAgreement : businessConfiguration.getSlAgreementList()) { if (slAgreement != null) { if (firstSlAgreement) { businessConfigurationElement.appendChild(hasSLAElement); firstSlAgreement = false; } hasSLAElement.appendChild(SLAgreementToXmlRdf.createSLAgreementElement(nameSpace, documentParent, slAgreement, slAgreement.getPathUri() + businessConfiguration.getLocalUri() + "_" + businessConfiguration.getSlAgreementList().indexOf(slAgreement))); } } return businessConfigurationElement; }
From source file:org.cloudsimulator.xml.rdf.xmlrdfconverter.DataCenterToXmlRdf.java
License:Open Source License
public static Element createDataCenterElement(final Namespace nameSpace, final Document documentParent, final DataCenter dataCenter) { Element dataCenterElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":DataCenter"); dataCenterElement.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":about", dataCenter.getUri()); dataCenterElement.appendChild(//from ww w. j a v a2 s .c o m XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasName", dataCenter.getHasName())); dataCenterElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasIdentifier", dataCenter.getHasIdentifier())); return dataCenterElement; }
From source file:org.cloudsimulator.xml.rdf.xmlrdfconverter.ExternalStorageToXmlRdf.java
License:Open Source License
public static Element createExternalStorageElement(final Namespace nameSpace, final Document documentParent, final ExternalStorage externalStorage) { Element externalStorageElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":ExternalStorage"); externalStorageElement.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":about", externalStorage.getUri()); externalStorageElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasName", externalStorage.getHasName())); externalStorageElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasIdentifier", externalStorage.getHasIdentifier())); externalStorageElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasModelName", externalStorage.getHasModelName())); boolean firstSharedStorageVolume = true; Element hasPartElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasPart"); for (SharedStorageVolume sharedStorageVolume : externalStorage.getSharedStorageVolumeList()) { if (sharedStorageVolume != null) { if (firstSharedStorageVolume) { externalStorageElement.appendChild(hasPartElement); firstSharedStorageVolume = false; }/*w w w .j a v a 2 s .co m*/ Element sharedStorageVolumeElement = SharedStorageVolumeToXmlRdf .createSharedStorageVolumeElement(nameSpace, documentParent, sharedStorageVolume); hasPartElement.appendChild(sharedStorageVolumeElement); } } boolean firstNetworkAdapter = true; Element hasNetworkAdapterElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasNetworkAdapter"); for (NetworkAdapter networkAdapter : externalStorage.getHasNetworkAdapterList()) { if (networkAdapter != null) { if (firstNetworkAdapter) { externalStorageElement.appendChild(hasNetworkAdapterElement); firstNetworkAdapter = false; } hasNetworkAdapterElement.appendChild(NetworkAdapterToXmlRdf.createNetworkAdapterElement(nameSpace, documentParent, networkAdapter)); } } externalStorageElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasMonitorIPAddress", externalStorage.getHasMonitorIPAddress())); boolean firstMonitorInfo = true; Element hasMonitorInfoElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasMonitorInfo"); for (MonitorInfo monitorInfo : externalStorage.getHasMonitorInfoList()) { if (monitorInfo != null) { if (firstMonitorInfo) { externalStorageElement.appendChild(hasMonitorInfoElement); firstMonitorInfo = false; } hasMonitorInfoElement.appendChild( MonitorInfoToXmlRdf.createMonitorInfoElement(nameSpace, documentParent, monitorInfo)); } } externalStorageElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasMonitorState", externalStorage.getHasMonitorState())); return externalStorageElement; }
From source file:org.cloudsimulator.xml.rdf.xmlrdfconverter.FirewallToRdf.java
License:Open Source License
public static Element createFirewallElement(final Namespace nameSpace, final Document documentParent, final Firewall firewall) { Element firewallElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":Firewall"); firewallElement.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":about", firewall.getUri()); firewallElement.appendChild(//from ww w . j av a2 s .c o m XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasName", firewall.getHasName())); firewallElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasIdentifier", firewall.getHasIdentifier())); firewallElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasModelName", firewall.getHasModelName())); boolean firstNetworkAdapter = true; Element hasNetworkAdapterElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasNetworkAdapter"); for (NetworkAdapter networkAdapter : firewall.getHasNetworkAdapterList()) { if (networkAdapter != null) { if (firstNetworkAdapter) { firewallElement.appendChild(hasNetworkAdapterElement); firstNetworkAdapter = false; } hasNetworkAdapterElement.appendChild(NetworkAdapterToXmlRdf.createNetworkAdapterElement(nameSpace, documentParent, networkAdapter)); } } firewallElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasMonitorIPAddress", firewall.getHasMonitorIPAddress())); boolean firstMonitorInfo = true; Element hasMonitorInfoElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasMonitorInfo"); for (MonitorInfo monitorInfo : firewall.getHasMonitorInfoList()) { if (monitorInfo != null) { if (firstMonitorInfo) { firewallElement.appendChild(hasMonitorInfoElement); firstMonitorInfo = false; } hasMonitorInfoElement.appendChild( MonitorInfoToXmlRdf.createMonitorInfoElement(nameSpace, documentParent, monitorInfo)); } } firewallElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasMonitorState", firewall.getHasMonitorState())); return firewallElement; }
From source file:org.cloudsimulator.xml.rdf.xmlrdfconverter.HostMachineToXmlRdf.java
License:Open Source License
public static Element createHostMachineElement(final Namespace nameSpace, final Document documentParent, final Element dataCenterElement, final String uriDataCenter, final HostMachine hostMachine) throws LocalNetworkTooLittleException { Element hasPartElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasPart"); hasPartElement.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":resource", hostMachine.getUri()); dataCenterElement.appendChild(hasPartElement); Element hostMachineElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":HostMachine"); hostMachineElement.setAttributeNS(NameSpaceRepository.RDF.getURI(), NameSpaceRepository.RDF.getPrefix() + ":about", hostMachine.getUri()); hostMachineElement.appendChild(/* w ww. j a v a2 s. c o m*/ XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasName", hostMachine.getHasName())); hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasIdentifier", hostMachine.getHasIdentifier())); hostMachineElement.appendChild(XmlUtility.createPositiveIntegerElement(nameSpace, documentParent, "hasCPUCount", hostMachine.getHasCPUCount())); hostMachineElement.appendChild(XmlUtility.createDecimalElement(nameSpace, documentParent, "hasCPUSpeed", hostMachine.getHasCPUSpeed())); hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasCPUType", hostMachine.getHasCPUType())); hostMachineElement.appendChild(XmlUtility.createDecimalElement(nameSpace, documentParent, "hasMemorySize", hostMachine.getHasMemorySize())); boolean firstLocalStorage = true; Element hasLocalStorageElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasLocalStorage"); for (LocalStorage localStorage : hostMachine.getHasLocalStorageList()) { if (localStorage != null) { if (firstLocalStorage) { hostMachineElement.appendChild(hasLocalStorageElement); firstLocalStorage = false; } hasLocalStorageElement.appendChild( LocalStorageToXmlRdf.createLocalStorageElement(nameSpace, documentParent, localStorage)); } } for (String uriSharedStorageVolume : hostMachine.getUseSharedStorageList()) { hostMachineElement.appendChild(XmlUtility.createResourceElement(nameSpace, documentParent, "useSharedStorage", uriSharedStorageVolume)); } boolean firstNetworkAdapter = true; Element hasNetworkAdapterElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasNetworkAdapter"); for (NetworkAdapter networkAdapter : hostMachine.getHasNetworkAdapterList()) { if (networkAdapter != null) { if (firstNetworkAdapter) { hostMachineElement.appendChild(hasNetworkAdapterElement); firstNetworkAdapter = false; } hasNetworkAdapterElement.appendChild(NetworkAdapterToXmlRdf.createNetworkAdapterElement(nameSpace, documentParent, networkAdapter)); } } hostMachineElement.appendChild(XmlUtility.createResourceElement(nameSpace, documentParent, "hasOS", "http://www.cloudicaro.it/cloud_ontology/core#" + hostMachine.getHasOS())); hostMachineElement.appendChild( XmlUtility.createResourceElement(nameSpace, documentParent, "isPartOf", uriDataCenter)); hostMachineElement.appendChild(XmlUtility.createDecimalElement(nameSpace, documentParent, "hasCapacity", hostMachine.getHasCapacity())); hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "isInDomain", hostMachine.getIsInDomain())); hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasAuthUserName", hostMachine.getHasAuthUserName())); hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasAuthUserPassword", hostMachine.getHasAuthUserPassword())); hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasMonitorIPAddress", hostMachine.getHasMonitorIPAddress())); boolean firstMonitorInfo = true; Element hasMonitorInfoElement = documentParent.createElementNS(nameSpace.getURI(), nameSpace.getPrefix() + ":hasMonitorInfo"); for (MonitorInfo monitorInfo : hostMachine.getHasMonitorInfoList()) { if (monitorInfo != null) { if (firstMonitorInfo) { hostMachineElement.appendChild(hasMonitorInfoElement); firstMonitorInfo = false; } hasMonitorInfoElement.appendChild( MonitorInfoToXmlRdf.createMonitorInfoElement(nameSpace, documentParent, monitorInfo)); } } hostMachineElement.appendChild(XmlUtility.createSimpleTextElement(nameSpace, documentParent, "hasMonitorState", hostMachine.getHasMonitorState())); return hostMachineElement; }