[brailleblaster] [brailleblaster.newdesign] push by john.bo...@xxxxxxxxxxxxxxxxx - saveEnhancedDocument using XPath on 2013-01-14 06:04 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Mon, 14 Jan 2013 06:04:21 +0000

Revision: 5e56cf2778af
Branch:   default
Author:   John Boyer <john.boyer@xxxxxxxxxxxxxxxxx>
Date:     Sun Jan 13 22:03:03 2013
Log:      saveEnhancedDocument using XPath
http://code.google.com/p/brailleblaster/source/detail?r=5e56cf2778af&repo=newdesign

Modified:
 /src/main/org/brailleblaster/document/DocumentBase.java
 /src/main/org/brailleblaster/document/Semantics.java

=======================================
--- /src/main/org/brailleblaster/document/DocumentBase.java Sat Jan 12 04:05:16 2013 +++ /src/main/org/brailleblaster/document/DocumentBase.java Sun Jan 13 22:03:03 2013
@@ -116,7 +116,7 @@
 }

 public Nodes getNodes (Node node, String xpathExpr) {
-return null;
+return sm.getNodes (node, xpathExpr);
 }

 public Node getContextNode() {
=======================================
--- /src/main/org/brailleblaster/document/Semantics.java Thu Jan 10 20:26:03 2013 +++ /src/main/org/brailleblaster/document/Semantics.java Sun Jan 13 22:03:03 2013
@@ -38,6 +38,7 @@
 import java.io.IOException;
 import nu.xom.Builder;
 import nu.xom.Node;
+import nu.xom.Nodes;
 import nu.xom.ParsingException;
 import nu.xom.Serializer;
 import nu.xom.Document;
@@ -523,6 +524,19 @@
 for (int i = 0; i < semanticsList.size(); i++) {
 }
 }
+
+/**
+ * Return a nodeset.
+ * @param node beginning node
+ * @param xpathExpr an XPath expression
+ */
+Nodes getNodes (Node node, String xpathExpr) {
+if (node == null) {
+return rootElement.query (xpathExpr);
+} else {
+return node.query (xpathExpr);
+}
+}

 /**
  * Save the file with utd markup so that work can be resumed at a later
@@ -543,7 +557,6 @@
 outputDoc.write(workingDocument);
 outputDoc.flush();
 } catch (IOException e) {
-//logger.log(Level.SEVERE, lh.localValue("cannotWriteFile") + ": " +
 new Notify(lh.localValue("cannotWriteFile"));
 return;
 }
@@ -557,6 +570,18 @@
  * is to be saved.
  */
 void saveEnhancedDocument(String fileName) {
+Node node;
+Nodes nodes;
+nodes = rootElement.query ("//meta[@name='brl']");
+node = nodes.get(0);
+node.detach();
+nodes = rootElement.query ("//brl");
+for (int i = 0; i < nodes.size(); i++) {
+node = nodes.get(i);
+node.detach();
+}
+nodes = null;
+saveWorkingFile (fileName);
 }

 }

Other related posts:

  • » [brailleblaster] [brailleblaster.newdesign] push by john.bo...@xxxxxxxxxxxxxxxxx - saveEnhancedDocument using XPath on 2013-01-14 06:04 GMT - brailleblaster