Skip to content

Commit

Permalink
v0.8.1
Browse files Browse the repository at this point in the history
- New functionality added to class `meico.msm.Msm`: method `addIds()` adds `xml:id` to each `note` and `rest` element that does not have one. MeicoApp has been updated accordingly.
  • Loading branch information
axelberndt committed Apr 14, 2020
1 parent 24e772b commit 33107d0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
### Version History


#### v0.8.1
- New functionality added to class `meico.msm.Msm`: method `addIds()` adds `xml:id` to each `note` and `rest` element that does not have one. MeicoApp has been updated accordingly.


#### v0.8.0
- Reorganization of the meico programming library and application code as well as its release assets.
- Meico is basically a programming library. All content of package `meico.app` is example code for meico's usage in application projects. However, for the graphical meico application certain JavaFX dependencies had to be added to meico which complicated development for other applications that do not rely on JavaFX. Thus, we decided to split the meico code base into the core functionality and the example applications.
Expand Down
2 changes: 1 addition & 1 deletion src/meico/Meico.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Axel Berndt
*/
public class Meico {
public static final String version = "0.8.0";
public static final String version = "0.8.1";

public static void main(String[] args) {
System.out.println("meico v" + Meico.version);
Expand Down
2 changes: 1 addition & 1 deletion src/meico/mei/Mei.java
Original file line number Diff line number Diff line change
Expand Up @@ -3562,7 +3562,7 @@ private synchronized Element resolveExpansions(Element root) {
* @return the generated ids count
*/
public synchronized int addIds() {
System.out.print("Adding IDs:");
System.out.print("Adding IDs to MEI:");
Element root = this.getRootElement();
if (root == null) {
System.err.println(" Error: no root element found");
Expand Down
25 changes: 25 additions & 0 deletions src/meico/msm/Msm.java
Original file line number Diff line number Diff line change
Expand Up @@ -1229,4 +1229,29 @@ private static long readMillisecondsDateFromElement(Element e) {
}
return Math.round(Double.parseDouble(dateAtt.getValue())); // Math.round(double) returns long
}

/**
* this method adds xml:ids to all note and rest elements, as far as they do not have an id
* @return the generated ids count
*/
public synchronized int addIds() {
System.out.print("Adding IDs to MSM:");
Element root = this.getRootElement();
if (root == null) {
System.err.println(" Error: no root element found");
return 0;
}

Nodes e = root.query("descendant::*[(local-name()='note' or local-name()='rest') and not(@xml:id)]");
for (int i = 0; i < e.size(); ++i) { // go through all the nodes
String uuid = "meico_" + UUID.randomUUID().toString(); // generate new ids for them
Attribute a = new Attribute("id", uuid); // create an attribute
a.setNamespace("xml", "http://www.w3.org/XML/1998/namespace"); // set its namespace to xml
((Element) e.get(i)).addAttribute(a); // add attribute to the node
}

System.out.println(" done");

return e.size();
}
}

0 comments on commit 33107d0

Please sign in to comment.