Changeset 961
- Timestamp:
- 08/05/09 21:34:46 (4 years ago)
- Location:
- src/jomdoc/trunk/src
- Files:
-
- 9 modified
-
jomdoc/org/omdoc/jomdoc/cli/JOMDoc.java (modified) (2 diffs)
-
jomdoc/org/omdoc/jomdoc/cli/JOMDocCommandEnvironment.java (modified) (4 diffs)
-
jomdoc/org/omdoc/jomdoc/cli/JOMDocOption.java (modified) (1 diff)
-
jomdoc/org/omdoc/jomdoc/cli/cmd/RenderCommand.java (modified) (1 diff)
-
jomdoc/org/omdoc/jomdoc/cli/cmd/TransformCommand.java (modified) (1 diff)
-
jomdoc/org/omdoc/jomdoc/cli/options.properties (modified) (1 diff)
-
jomdoc/org/omdoc/jomdoc/util/xml/XMLUtil.java (modified) (1 diff)
-
jomdoc/org/omdoc/jomdoc/util/xml/XSLTUtil.java (modified) (1 diff)
-
test/org/omdoc/jomdoc/cli/JOMDocTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/JOMDoc.java
r918 r961 240 240 241 241 CommandLine.registerOption(JOMDocOption.ASCII_XML); 242 CommandLine.registerOption(JOMDocOption.NO_PRETTY_PRINT); 242 243 } 243 244 … … 290 291 if (doc != null && output != null) { 291 292 try { 292 XMLUtil.serialize(doc, output); 293 if (JOMDocCommandEnvironment.noPrettyPrint) 294 XMLUtil.rawSerialize(doc, output); 295 else 296 XMLUtil.serialize(doc, output); 293 297 // new Serializer (output, "UTF-8").write (doc); 294 298 } catch (UnsupportedEncodingException e) { -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/JOMDocCommandEnvironment.java
r960 r961 84 84 85 85 private boolean asciiXML; 86 public static boolean noPrettyPrint; 86 87 87 88 public JOMDocCommandEnvironment(String programName, PrintStream out, PrintStream err, InputStream in) { … … 151 152 return; 152 153 } 154 noPrettyPrint = false; 153 155 154 156 File file = null; … … 223 225 } else if (option == JOMDocOption.ASCII_XML) { 224 226 asciiXML = true; 227 } else if (option == JOMDocOption.NO_PRETTY_PRINT) { 228 noPrettyPrint = true; 225 229 } else { 226 230 Log.error("Unknown option: " + option); … … 383 387 return replaceXPaths; 384 388 } 389 390 public boolean isNoPrettyPrint() { 391 return noPrettyPrint; 392 } 385 393 } -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/JOMDocOption.java
r960 r961 73 73 74 74 public static final JOMDocOption ASCII_XML = new JOMDocOption("ascii-xml"); 75 public static final JOMDocOption NO_PRETTY_PRINT = new JOMDocOption("no-pretty-print"); 75 76 76 77 private JOMDocOption(String name) { -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/cmd/RenderCommand.java
r665 r961 108 108 options.add(JOMDocOption.RENDERING_INFO); 109 109 options.add(JOMDocOption.PROTOTYPE_INFO); 110 options.add(JOMDocOption.NO_PRETTY_PRINT); 110 111 111 112 return options; -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/cmd/TransformCommand.java
r960 r961 100 100 101 101 options.add(JOMDocOption.ASCII_XML); 102 options.add(JOMDocOption.NO_PRETTY_PRINT); 102 103 103 104 return options; -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/options.properties
r960 r961 64 64 65 65 ascii-xml=transform notation definitions from ASCII to XML 66 no-pretty-print=don't pretty print the output -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/util/xml/XMLUtil.java
r918 r961 220 220 /** 221 221 * Serialize a XOM Document. 222 * 222 * 223 223 * @param xomDocument the XOM Document to be serialized 224 224 * @param os stream where to write the result 225 * @throws IOException 225 * @throws IOException 226 */ 227 public static String rawSerialize(Document xomDocument) throws IOException { 228 OutputStream os = new ByteArrayOutputStream(); 229 rawSerialize(xomDocument, os); 230 return os.toString(); 231 } 232 233 /** 234 * Serialize a XOM Document. 235 * 236 * @param xomDocument the XOM Document to be serialized 237 * @param os stream where to write the result 238 * @throws IOException 226 239 */ 227 240 public static void serialize(Document xomDocument, OutputStream os) throws IOException { 228 241 nu.xom.Serializer serializer = new nu.xom.Serializer(os); 229 242 serializer.setIndent(2); 243 serializer.write(xomDocument); 244 } 245 246 /** 247 * Serialize a XOM Document without pretty printing the result. 248 * 249 * @param xomDocument the XOM Document to be serialized 250 * @param os stream where to write the result 251 * @throws IOException 252 */ 253 public static void rawSerialize(Document xomDocument, OutputStream os) throws IOException { 254 nu.xom.Serializer serializer = new nu.xom.Serializer(os); 230 255 serializer.write(xomDocument); 231 256 } -
src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/util/xml/XSLTUtil.java
r920 r961 270 270 public static Document getDefaultXSLT() throws IOException, ParsingException { 271 271 if (defaultXslt == null) { 272 InputStream is = XSLTUtil.class.getResourceAsStream(XSLT_DIR + DEFAULT_XSLT_FILE); 273 defaultXslt = XMLUtil.buildDocument(null, is); 272 try { 273 InputStream is = XSLTUtil.class.getResourceAsStream(XSLT_DIR + DEFAULT_XSLT_FILE); 274 defaultXslt = XMLUtil.buildDocument(null, is); 275 } catch (Exception ex) { 276 ex.printStackTrace(); 277 } 274 278 } 275 279 -
src/jomdoc/trunk/src/test/org/omdoc/jomdoc/cli/JOMDocTest.java
r958 r961 165 165 render(IN + "quant2.omdoc", "-o", OUT + "quant2.omdoc"); 166 166 } 167 168 @Ignore 169 @Test 170 public void testNoPrettyPrint() { 171 String out = OUT + "noPrettyPrint.omdoc"; 172 String inp = IN + "binomial.omdoc"; 173 render(inp, "-o", out, "-X", "--no-pretty-print"); 174 rm(out); 175 } 167 176 }
