List of usage examples for org.jdom2 Attribute getName
public String getName()
Attribute
. From source file:org.mycore.mir.wizard.command.MIRWizardMCRCommand.java
License:Open Source License
@Override public void doExecute() { Session currentSession = MCRHIBConnection.instance().getSession(); try {// w w w . ja v a 2s . c om for (Element command : getInputXML().getChildren()) { String cmd = command.getTextTrim(); cmd = cmd.replaceAll("\n", "").replaceAll("\r", "").replaceAll(" ", " "); cmd = cmd.replaceAll(" ", " "); for (Attribute attr : command.getAttributes()) { if (attr.getValue().startsWith("resource:")) { File tmpFile = File.createTempFile("resfile", ".xml"); MCRContent source = new MCRJDOMContent(MCRURIResolver.instance().resolve(attr.getValue())); source.sendTo(tmpFile); cmd = cmd.replace("{" + attr.getName() + "}", tmpFile.getAbsolutePath()); } else { cmd = cmd.replace("{" + attr.getName() + "}", attr.getValue()); } } MCRCommandManager mcrCmdMgr = new MCRCommandManager(); Transaction tx = currentSession.beginTransaction(); try { mcrCmdMgr.invokeCommand(cmd); tx.commit(); } catch (HibernateException e) { tx.rollback(); this.result.setResult(result + e.toString()); this.result.setSuccess(false); return; } catch (InvocationTargetException e) { e.printStackTrace(); this.result.setResult(result + e.toString()); this.result.setSuccess(false); return; } } this.result.setSuccess(true); } catch (Exception ex) { ex.printStackTrace(); this.result.setResult(ex.toString()); this.result.setSuccess(false); } }
From source file:org.olanto.myterm.extractor.model.posfix.LoadModelPosfix.java
License:Open Source License
static String getExtraElement(Element e) { StringBuilder collect = new StringBuilder(); boolean attributeverbose = false; collect.append("<" + e.getName()); List<Attribute> attlist = e.getAttributes(); Iterator i = attlist.iterator(); while (i.hasNext()) { Attribute att = (Attribute) i.next(); String av = att.getName() + "=\"" + getAtt(e, att.getName(), noNS, attributeverbose) + "\""; collect.append(" " + av); //System.out.println(av); }//from w ww. ja va 2 s. c o m collect.append(">"); List listNode = e.getChildren(); i = listNode.iterator(); while (i.hasNext()) { Element info = (Element) i.next(); collect.append("\n"); collect.append(getExtraElement(info)); } //System.out.println(e.getTextTrim()); collect.append(e.getTextNormalize()); collect.append("</" + e.getName() + ">"); String res = collect.toString(); res = res.replace("><", ">\n<"); res = res.replace(" ", " "); //System.out.println(res); return res; }
From source file:org.openconcerto.xml.JDOM2Utils.java
License:Open Source License
static String getDiff(Element elem1, Element elem2, final boolean normalizeText) { if (elem1 == elem2) return null; if (!equals(elem1, elem2)) return "element name or namespace"; // ignore attributes order final List<Attribute> attr1 = elem1.getAttributes(); final List<Attribute> attr2 = elem2.getAttributes(); if (attr1.size() != attr2.size()) return "attributes count"; for (final Attribute attr : attr1) { if (!attr.getValue().equals(elem2.getAttributeValue(attr.getName(), attr.getNamespace()))) return "attribute value"; }/*from ww w. j a va2s . c om*/ // use content order final IPredicate<Content> filter = new IPredicate<Content>() { @Override public boolean evaluateChecked(Content input) { return input instanceof Text || input instanceof Element; } }; // only check Element and Text (also merge them) final Iterator<Content> contents1 = getContent(elem1, filter, true); final Iterator<Content> contents2 = getContent(elem2, filter, true); while (contents1.hasNext() && contents2.hasNext()) { final Content content1 = contents1.next(); final Content content2 = contents2.next(); if (content1.getClass() != content2.getClass()) return "content"; if (content1 instanceof Text) { final String s1 = normalizeText ? ((Text) content1).getTextNormalize() : content1.getValue(); final String s2 = normalizeText ? ((Text) content2).getTextNormalize() : content2.getValue(); if (!s1.equals(s2)) return "text"; } else { final String rec = getDiff((Element) content1, (Element) content2, normalizeText); if (rec != null) return rec; } } if (contents1.hasNext() || contents2.hasNext()) return "content size"; return null; }
From source file:org.openflexo.foundation.fml.rm.ViewPointResourceImpl.java
License:Open Source License
private static ViewPointInfo findViewPointInfo(InputStream inputStream) { Document document;/*w w w . j a v a2 s . co m*/ try { document = readXMLInputStream(inputStream); Element root = getElement(document, "ViewPoint"); if (root != null) { ViewPointInfo returned = new ViewPointInfo(); Iterator<Attribute> it = root.getAttributes().iterator(); while (it.hasNext()) { Attribute at = it.next(); if (at.getName().equals("uri")) { logger.fine("Returned " + at.getValue()); returned.uri = at.getValue(); } else if (at.getName().equals("name")) { logger.fine("Returned " + at.getValue()); returned.name = at.getValue(); } else if (at.getName().equals("version")) { logger.fine("Returned " + at.getValue()); returned.version = at.getValue(); } else if (at.getName().equals("modelVersion")) { logger.fine("Returned " + at.getValue()); returned.modelVersion = at.getValue(); } } if (StringUtils.isEmpty(returned.name)) { if (StringUtils.isNotEmpty(returned.uri)) { if (returned.uri.indexOf("/") > -1) { returned.name = returned.uri.substring(returned.uri.lastIndexOf("/") + 1); } else if (returned.uri.indexOf("\\") > -1) { returned.name = returned.uri.substring(returned.uri.lastIndexOf("\\") + 1); } else { returned.name = returned.uri; } } } return returned; } } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } logger.fine("Returned null"); return null; }
From source file:org.openflexo.foundation.fml.rm.ViewPointResourceImpl.java
License:Open Source License
private static void convertNames16ToNames17(Document document) { // Convert common properties addProperty("userID", "FLX", document, null); // Edition Patterns // Edition patterns name convertOldNameToNewNames("EditionPattern", "FlexoConcept", document); // Parent pattern property is no more an attribute but an element IteratorIterable<? extends Content> fcElementsIterator = document .getDescendants(new ElementFilter("FlexoConcept")); List<Element> fcElements = IteratorUtils.toList(fcElementsIterator); for (Element fc : fcElements) { if (fc.getAttribute("parentEditionPattern") != null) { Element parentEp = new Element("ParentFlexoConcept"); Attribute parentIdRef = new Attribute("idref", getFlexoConceptID(document, fc.getAttributeValue("parentEditionPattern"))); parentEp.getAttributes().add(parentIdRef); fc.removeAttribute("parentEditionPattern"); fc.addContent(parentEp);//ww w . j av a 2s .co m } } // Pattern Roles // Pattern roles properties changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document, "ContainedEditionPatternInstancePatternRole"); changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document, "AddressedSelectEditionPatternInstance"); changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document, "SelectEditionPatternInstance"); changePropertyName("editionPatternTypeURI", "flexoConceptTypeURI", document, "EditionPatternInstanceParameter"); changePropertyName("paletteElementID", "paletteElementId", document, "FMLDiagramPaletteElementBinding"); changePropertyName("editionPattern", "flexoConcept", document, "PaletteElement"); removeProperties("patternRole", document); removeProperty("className", document, "DrawingGraphicalRepresentation"); removeProperty("className", document, "ShapeGraphicalRepresentation"); removeProperty("className", document, "ConnectorGraphicalRepresentation"); // Pattern roles name convertOldNameToNewNames("ContainedEditionPatternInstancePatternRole", "FlexoConceptInstanceRole", document); convertOldNameToNewNames("EditionPatternInstancePatternRole", "FlexoConceptInstanceRole", document); convertOldNameToNewNames("ContainedShapePatternRole", "ShapeRole", document); convertOldNameToNewNames("ShapePatternRole", "ShapeRole", document); convertOldNameToNewNames("ContextShapePatternRole", "ShapeRole", document); convertOldNameToNewNames("ParentShapePatternRole", "ParentShapeRole", document); convertOldNameToNewNames("ContainedEMFObjectIndividualPatternRole", "EMFObjectIndividualRole", document); convertOldNameToNewNames("EMFObjectIndividualPatternRole", "EMFObjectIndividualRole", document); convertOldNameToNewNames("ContainedConnectorPatternRole", "ConnectorRole", document); convertOldNameToNewNames("ConnectorPatternRole", "ConnectorRole", document); convertOldNameToNewNames("ContainedOWLIndividualPatternRole", "OWLIndividualRole", document); convertOldNameToNewNames("OWLIndividualPatternRole", "OWLIndividualRole", document); convertOldNameToNewNames("ContainedObjectPropertyStatementPatternRole", "ObjectPropertyStatementRole", document); convertOldNameToNewNames("ObjectPropertyStatementPatternRole", "ObjectPropertyStatementRole", document); convertOldNameToNewNames("ContainedDataPropertyStatementPatternRole", "DataPropertyStatementRole", document); convertOldNameToNewNames("DataPropertyStatementPatternRole", "DataPropertyStatementRole", document); convertOldNameToNewNames("ContainedExcelCellPatternRole", "ExcelCellRole", document); convertOldNameToNewNames("ExcelCellPatternRole", "ExcelCellRole", document); convertOldNameToNewNames("ContainedExcelSheetPatternRole", "ExcelSheetRole", document); convertOldNameToNewNames("ExcelSheetPatternRole", "ExcelSheetRole", document); convertOldNameToNewNames("ContainedExcelRowPatternRole", "ExcelRowRole", document); convertOldNameToNewNames("ExcelRowPatternRole", "ExcelRowRole", document); convertOldNameToNewNames("ContainedDiagramPatternRole", "DiagramRole", document); convertOldNameToNewNames("DiagramPatternRole", "DiagramRole", document); convertOldNameToNewNames("ContainedXMLIndividualPatternRole", "XMLIndividualRole", document); convertOldNameToNewNames("XMLIndividualPatternRole", "XMLIndividualRole", document); convertOldNameToNewNames("ContainedXSIndividualPatternRole", "XSIndividualRole", document); convertOldNameToNewNames("XSIndividualPatternRole", "XSIndividualRole", document); convertOldNameToNewNames("ContainedXSClassPatternRole", "XSClassRole", document); convertOldNameToNewNames("XSClassPatternRole", "XSClassRole", document); // Actions convertOldNameToNewNames("EditionPatternInstanceParameter", "FlexoConceptInstanceParameter", document); convertOldNameToNewNames("MatchEditionPatternInstance", "MatchFlexoConceptInstance", document); convertOldNameToNewNames("CreateEditionPatternInstanceParameter", "CreateFlexoConceptInstanceParameter", document); // Retrieve Fetch Actions IteratorIterable<? extends Content> fetchElementsIterator = document .getDescendants(new ElementFilter("FetchRequestIterationAction")); List<Element> fetchElements = IteratorUtils.toList(fetchElementsIterator); for (Element fetchElement : fetchElements) { for (Element child : fetchElement.getChildren()) { if (child.getName().equals("AddressedSelectEditionPatternInstance")) { child.setName("FetchRequest_SelectFlexoConceptInstance"); } if (child.getName().equals("AddressedSelectEMFObjectIndividual")) { child.setName("FetchRequest_SelectEMFObjectIndividual"); } if (child.getName().equals("AddressedSelectIndividual")) { child.setName("FetchRequest_SelectIndividual"); } if (child.getName().equals("AddressedSelectExcelCell")) { child.setName("FetchRequest_SelectExcelCell"); } if (child.getName().equals("AddressedSelectExcelRow")) { child.setName("FetchRequest_SelectExcelRow"); } if (child.getName().equals("AddressedSelectExcelSheet")) { child.setName("FetchRequest_SelectExcelSheet"); } if (child.getName().equals("AddressedSelectEditionPatternInstance")) { child.setName("FetchRequest_SelectFlexoConceptInstance"); } } } // Built-in actions convertOldNameToNewNames("DeclareFlexoRole", "DeclareFlexoRole", document); convertOldNameToNewNames("AddEditionPatternInstance", "AddFlexoConceptInstance", document); convertOldNameToNewNames("AddEditionPatternInstanceParameter", "AddFlexoConceptInstanceParameter", document); convertOldNameToNewNames("AddressedSelectEditionPatternInstance", "SelectFlexoConceptInstance", document); convertOldNameToNewNames("AddressedSelectFlexoConceptInstance", "SelectFlexoConceptInstance", document); convertOldNameToNewNames("SelectEditionPatternInstance", "SelectFlexoConceptInstance", document); // Model Slots for (Content content : document.getDescendants()) { if (content instanceof Element) { Element element = (Element) content; if ((element.getParentElement() != null) && (element.getParentElement().getName().equals("DiagramSpecification") || element.getParentElement().getName().equals("VirtualModel"))) { if (element.getName().equals("EMFModelSlot")) { element.setName("ModelSlot_EMFModelSlot"); } else if (element.getName().equals("XMLModelSlot")) { element.setName("ModelSlot_XMLModelSlot"); } else if (element.getName().equals("XSDModelSlot")) { element.setName("ModelSlot_XSDModelSlot"); } else if (element.getName().equals("BasicExcelModelSlot")) { element.setName("ModelSlot_BasicExcelModelSlot"); } else if (element.getName().equals("SemanticsExcelModelSlot")) { element.setName("ModelSlot_SemanticsExcelModelSlot"); } else if (element.getName().equals("BasicPowerpointModelSlot")) { element.setName("ModelSlot_SemanticsPowerpointModelSlot"); } else if (element.getName().equals("OWLModelSlot")) { element.setName("ModelSlot_OWLModelSlot"); } else if (element.getName().equals("FMLRTModelSlot")) { element.setName("ModelSlot_VirtualModelModelSlot"); } } else { if (element.getName().equals("AddressedEMFModelSlot")) { element.setName("EMFModelSlot"); } else if (element.getName().equals("AddressedXMLModelSlot")) { element.setName("XMLModelSlot"); } else if (element.getName().equals("AddressedXSDModelSlot")) { element.setName("XSDModelSlot"); } else if (element.getName().equals("AddressedBasicExcelModelSlot")) { element.setName("BasicExcelModelSlot"); } else if (element.getName().equals("AddressedSemanticsExcelModelSlot")) { element.setName("SemanticsExcelModelSlot"); } else if (element.getName().equals("AddressedBasicPowerpointModelSlot")) { element.setName("BasicPowerpointModelSlot"); } else if (element.getName().equals("AddressedSemanticsPowerpointModelSlot")) { element.setName("SemanticsPowerpointModelSlot"); } else if (element.getName().equals("AddressedOWLModelSlot")) { element.setName("OWLModelSlot"); } else if (element.getName().equals("AddressedDiagramModelSlot")) { element.setName("TypedDiagramModelSlot"); } else if (element.getName().equals("AddressedVirtualModelModelSlot")) { element.setName("FMLRTModelSlot"); } } } } // Palettes/ExampleDiagrams // Retrieve Connector GRs IteratorIterable<? extends Content> connectorGRElementsIterator = document .getDescendants(new ElementFilter("ConnectorGraphicalRepresentation")); List<Element> connectorGRElements = IteratorUtils.toList(connectorGRElementsIterator); for (Element connectorGRElement : connectorGRElements) { Element grSpec = null; if (connectorGRElement.getChild("RectPolylinConnector") != null) { grSpec = connectorGRElement.getChild("RectPolylinConnector"); } else if (connectorGRElement.getChild("LineConnector") != null) { grSpec = connectorGRElement.getChild("LineConnector"); } else if (connectorGRElement.getChild("CurvedPolylinConnector") != null) { grSpec = connectorGRElement.getChild("CurvedPolylinConnector"); } else if (connectorGRElement.getChild("ArcConnector") != null) { grSpec = connectorGRElement.getChild("ArcConnector"); } if (connectorGRElement.getAttribute("startSymbol") != null) { Attribute startSymbol = new Attribute("startSymbol", connectorGRElement.getAttributeValue("startSymbol")); grSpec.getAttributes().add(startSymbol); connectorGRElement.removeAttribute("startSymbol"); } if (connectorGRElement.getAttribute("endSymbol") != null) { Attribute endSymbol = new Attribute("endSymbol", connectorGRElement.getAttributeValue("endSymbol")); grSpec.getAttributes().add(endSymbol); connectorGRElement.removeAttribute("endSymbol"); } if (connectorGRElement.getAttribute("middleSymbol") != null) { Attribute middleSymbol = new Attribute("middleSymbol", connectorGRElement.getAttributeValue("middleSymbol")); grSpec.getAttributes().add(middleSymbol); connectorGRElement.removeAttribute("middleSymbol"); } if (connectorGRElement.getAttribute("startSymbolSize") != null) { Attribute startSymbolSize = new Attribute("startSymbolSize", connectorGRElement.getAttributeValue("startSymbolSize")); grSpec.getAttributes().add(startSymbolSize); connectorGRElement.removeAttribute("startSymbolSize"); } if (connectorGRElement.getAttribute("endSymbolSize") != null) { Attribute endSymbolSize = new Attribute("endSymbolSize", connectorGRElement.getAttributeValue("endSymbolSize")); grSpec.getAttributes().add(endSymbolSize); connectorGRElement.removeAttribute("endSymbolSize"); } if (connectorGRElement.getAttribute("middleSymbolSize") != null) { Attribute middleSymbolSize = new Attribute("middleSymbolSize", connectorGRElement.getAttributeValue("middleSymbolSize")); grSpec.getAttributes().add(middleSymbolSize); connectorGRElement.removeAttribute("middleSymbolSize"); } if (connectorGRElement.getAttribute("relativeMiddleSymbolLocation") != null) { Attribute relativeMiddleSymbolLocation = new Attribute("relativeMiddleSymbolLocation", connectorGRElement.getAttributeValue("relativeMiddleSymbolLocation")); grSpec.getAttributes().add(relativeMiddleSymbolLocation); connectorGRElement.removeAttribute("relativeMiddleSymbolLocation"); } } convertOldNameToNewNames("Palette", "DiagramPalette", document); convertOldNameToNewNames("PaletteElement", "DiagramPaletteElement", document); convertOldNameToNewNames("Shema", "Diagram", document); convertOldNameToNewNames("ContainedShape", "Shape", document); convertOldNameToNewNames("ContainedConnector", "Connector", document); convertOldNameToNewNames("FromShape", "StartShape", document); convertOldNameToNewNames("ToShape", "EndShape", document); convertOldNameToNewNames("Border", "ShapeBorder", document); convertOldNameToNewNames("LineConnector", "LineConnectorSpecification", document); convertOldNameToNewNames("CurvedPolylinConnector", "CurvedPolylinConnectorSpecification", document); convertOldNameToNewNames("RectPolylinConnector", "RectPolylinConnectorSpecification", document); removeNamedElements(document, "PrimaryConceptOWLIndividualPatternRole"); removeNamedElements(document, "StartShapeGraphicalRepresentation"); removeNamedElements(document, "EndShapeGraphicalRepresentation"); removeNamedElements(document, "ArtifactFromShapeGraphicalRepresentation"); removeNamedElements(document, "ArtifactToShapeGraphicalRepresentation"); removeNamedElements(document, "PrimaryRepresentationConnectorPatternRole"); removeNamedElements(document, "PrimaryRepresentationShapePatternRole"); removeNamedElements(document, "PrimaryConceptObjectPropertyStatementPatternRole"); removeNamedElements(document, "ToShapePatternRole"); removeNamedElements(document, "StartShapeGraphicalRepresentation"); removeNamedElements(document, "EndShapeGraphicalRepresentation"); // Change all "this" for (Content content : document.getDescendants()) { if (content instanceof Element) { Element element = (Element) content; for (Attribute attribute : element.getAttributes()) { if (attribute.getValue().startsWith("this")) { if (element.getName().equals("ModelSlot_VirtualModelModelSlot")) { attribute.setValue(attribute.getValue().replace("this", "virtualModelInstance")); } if (element.getName().equals("FMLRTModelSlot")) { attribute.setValue(attribute.getValue().replace("this", "virtualModelInstance")); } if (attribute.getName().equals("virtualModelInstance")) { attribute.setValue(attribute.getValue().replace("this", "virtualModelInstance")); } else { attribute.setValue(attribute.getValue().replace("this", "flexoBehaviourInstance")); } } } } } }
From source file:org.openflexo.foundation.fml.rm.VirtualModelResourceImpl.java
License:Open Source License
private static VirtualModelInfo findVirtualModelInfo(InputStream inputStream) { Document document;//from w ww. j a v a 2s . c o m try { // logger.fine("Try to find infos for " + virtualModelDirectory); // String baseName = virtualModelDirectory.getName(); // File xmlFile = new File(virtualModelDirectory, baseName + ".xml"); // if (xmlFile.exists()) { document = readXMLInputStream(inputStream);// (xmlFile); Element root = getElement(document, "VirtualModel"); if (root != null) { VirtualModelInfo returned = new VirtualModelInfo(); Iterator<Attribute> it = root.getAttributes().iterator(); while (it.hasNext()) { Attribute at = it.next(); if (at.getName().equals("name")) { logger.fine("Returned " + at.getValue()); returned.name = at.getValue(); } else if (at.getName().equals("version")) { logger.fine("Returned " + at.getValue()); returned.version = at.getValue(); } else if (at.getName().equals("modelVersion")) { logger.fine("Returned " + at.getValue()); returned.modelVersion = at.getValue(); } } if (StringUtils.isEmpty(returned.name)) { // returned.name = virtualModelDirectory.getName(); returned.name = "NoName"; } return returned; } /*} else { logger.warning("While analysing virtual model candidate: " + virtualModelDirectory.getAbsolutePath() + " cannot find file " + xmlFile.getAbsolutePath()); }*/ } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } logger.fine("Returned null"); return null; }
From source file:org.openflexo.foundation.fml.rt.rm.ViewResourceImpl.java
License:Open Source License
private static ViewInfo findViewInfo(File viewDirectory) { Document document;//from w w w. java 2 s . co m try { logger.fine("Try to find infos for " + viewDirectory); String baseName = viewDirectory.getName().substring(0, viewDirectory.getName().length() - 5); File xmlFile = new File(viewDirectory, baseName + ".xml"); if (xmlFile.exists()) { document = XMLUtils.readXMLFile(xmlFile); Element root = XMLUtils.getElement(document, "View"); if (root != null) { ViewInfo returned = new ViewInfo(); returned.name = baseName; Iterator<Attribute> it = root.getAttributes().iterator(); while (it.hasNext()) { Attribute at = it.next(); if (at.getName().equals("viewPointURI")) { logger.fine("Returned " + at.getValue()); returned.viewPointURI = at.getValue(); } else if (at.getName().equals("viewPointVersion")) { logger.fine("Returned " + at.getValue()); returned.viewPointVersion = at.getValue(); } } return returned; } } else { logger.warning("Cannot find file: " + xmlFile.getAbsolutePath()); } } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } logger.fine("Returned null"); return null; }
From source file:org.openflexo.foundation.fml.rt.rm.VirtualModelInstanceResourceImpl.java
License:Open Source License
protected static VirtualModelInstanceInfo findVirtualModelInstanceInfo(File virtualModelInstanceFile, String searchedRootXMLTag) { Document document;/* w w w.j a v a2s.c o m*/ try { logger.fine("Try to find infos for " + virtualModelInstanceFile); String baseName = virtualModelInstanceFile.getName().substring(0, virtualModelInstanceFile.getName().length() - VirtualModelInstanceResource.VIRTUAL_MODEL_SUFFIX.length()); if (virtualModelInstanceFile.exists()) { document = XMLUtils.readXMLFile(virtualModelInstanceFile); Element root = XMLUtils.getElement(document, searchedRootXMLTag); if (root != null) { VirtualModelInstanceInfo returned = new VirtualModelInstanceInfo(); returned.name = baseName; Iterator<Attribute> it = root.getAttributes().iterator(); while (it.hasNext()) { Attribute at = it.next(); if (at.getName().equals("virtualModelURI")) { logger.fine("Returned " + at.getValue()); returned.virtualModelURI = at.getValue(); } } return returned; } } else { logger.warning("Cannot find file: " + virtualModelInstanceFile.getAbsolutePath()); } } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } logger.fine("Returned null"); return null; }
From source file:org.openflexo.foundation.ontology.owl.OWLOntology.java
License:Open Source License
private static String findOntologyURIWithRDFBaseMethod(File aFile) { Document document;/* www. j a v a 2 s . co m*/ try { logger.fine("Try to find URI for " + aFile); document = readXMLFile(aFile); Element root = getElement(document, "RDF"); if (root != null) { Iterator it = root.getAttributes().iterator(); while (it.hasNext()) { Attribute at = (Attribute) it.next(); if (at.getName().equals("base")) { logger.fine("Returned " + at.getValue()); return at.getValue(); } } } } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } logger.fine("Returned null"); return null; }
From source file:org.openflexo.foundation.ontology.owl.OWLOntology.java
License:Open Source License
private static String findOntologyURIWithOntologyAboutMethod(File aFile) { Document document;/*w w w.j a va 2 s.c o m*/ try { logger.fine("Try to find URI for " + aFile); document = readXMLFile(aFile); Element root = getElement(document, "Ontology"); if (root != null) { Iterator it = root.getAttributes().iterator(); while (it.hasNext()) { Attribute at = (Attribute) it.next(); if (at.getName().equals("about")) { logger.fine("Returned " + at.getValue()); String returned = at.getValue(); if (StringUtils.isNotEmpty(returned)) { return returned; } } } } } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } logger.fine("Returned null"); return findOntologyURIWithRDFBaseMethod(aFile); }