Changeset 961

Show
Ignore:
Timestamp:
08/05/09 21:34:46 (4 years ago)
Author:
dmisev
Message:

#472

Location:
src/jomdoc/trunk/src
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/JOMDoc.java

    r918 r961  
    240240 
    241241        CommandLine.registerOption(JOMDocOption.ASCII_XML); 
     242        CommandLine.registerOption(JOMDocOption.NO_PRETTY_PRINT); 
    242243    } 
    243244 
     
    290291        if (doc != null && output != null) { 
    291292            try { 
    292                 XMLUtil.serialize(doc, output); 
     293                if (JOMDocCommandEnvironment.noPrettyPrint) 
     294                    XMLUtil.rawSerialize(doc, output); 
     295                else 
     296                    XMLUtil.serialize(doc, output); 
    293297//        new Serializer (output, "UTF-8").write (doc); 
    294298            } catch (UnsupportedEncodingException e) { 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/JOMDocCommandEnvironment.java

    r960 r961  
    8484 
    8585    private boolean asciiXML; 
     86    public static boolean noPrettyPrint; 
    8687 
    8788    public JOMDocCommandEnvironment(String programName, PrintStream out, PrintStream err, InputStream in) { 
     
    151152            return; 
    152153        } 
     154        noPrettyPrint = false; 
    153155 
    154156        File file = null; 
     
    223225        } else if (option == JOMDocOption.ASCII_XML) { 
    224226            asciiXML = true; 
     227        } else if (option == JOMDocOption.NO_PRETTY_PRINT) { 
     228            noPrettyPrint = true; 
    225229        } else { 
    226230            Log.error("Unknown option: " + option); 
     
    383387        return replaceXPaths; 
    384388    } 
     389 
     390    public boolean isNoPrettyPrint() { 
     391        return noPrettyPrint; 
     392    } 
    385393} 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/JOMDocOption.java

    r960 r961  
    7373 
    7474    public static final JOMDocOption ASCII_XML = new JOMDocOption("ascii-xml"); 
     75    public static final JOMDocOption NO_PRETTY_PRINT = new JOMDocOption("no-pretty-print"); 
    7576     
    7677    private JOMDocOption(String name) { 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/cmd/RenderCommand.java

    r665 r961  
    108108        options.add(JOMDocOption.RENDERING_INFO); 
    109109        options.add(JOMDocOption.PROTOTYPE_INFO); 
     110        options.add(JOMDocOption.NO_PRETTY_PRINT); 
    110111 
    111112        return options; 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/cmd/TransformCommand.java

    r960 r961  
    100100 
    101101        options.add(JOMDocOption.ASCII_XML); 
     102        options.add(JOMDocOption.NO_PRETTY_PRINT); 
    102103 
    103104        return options; 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/cli/options.properties

    r960 r961  
    6464 
    6565ascii-xml=transform notation definitions from ASCII to XML 
     66no-pretty-print=don't pretty print the output 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/util/xml/XMLUtil.java

    r918 r961  
    220220    /** 
    221221     * Serialize a XOM Document. 
    222      *  
     222     * 
    223223     * @param xomDocument the XOM Document to be serialized 
    224224     * @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 
    226239     */ 
    227240    public static void serialize(Document xomDocument, OutputStream os) throws IOException { 
    228241        nu.xom.Serializer serializer = new nu.xom.Serializer(os); 
    229242        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); 
    230255        serializer.write(xomDocument); 
    231256    } 
  • src/jomdoc/trunk/src/jomdoc/org/omdoc/jomdoc/util/xml/XSLTUtil.java

    r920 r961  
    270270    public static Document getDefaultXSLT() throws IOException, ParsingException { 
    271271        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        } 
    274278        } 
    275279 
  • src/jomdoc/trunk/src/test/org/omdoc/jomdoc/cli/JOMDocTest.java

    r958 r961  
    165165        render(IN + "quant2.omdoc", "-o", OUT + "quant2.omdoc"); 
    166166    } 
     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    } 
    167176}