foray-commit Mailing List for FOray (Page 316)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(4) |
Dec
(23) |
| 2026 |
Jan
(119) |
Feb
(335) |
Mar
(103) |
Apr
(43) |
May
(154) |
Jun
(107) |
Jul
(187) |
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2006-04-26 01:02:49
|
Revision: 7064 Author: victormote Date: 2006-04-25 18:02:45 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7064&view=rev Log Message: ----------- Fix bug in outline creation. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutline.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutline.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutline.java 2006-04-26 00:27:11 UTC (rev 7063) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutline.java 2006-04-26 01:02:45 UTC (rev 7064) @@ -49,7 +49,7 @@ StringBuffer result = new StringBuffer(); result.append(this.pdfID() + EOL); result.append("<<" + EOL); - result.append(" /Type Outlines" + EOL); + result.append(" /Type /Outlines" + EOL); if (getFirst() != null && getLast() != null) { result.append(" /First " + getFirst().pdfReference() + EOL); result.append(" /Last " + getLast().pdfReference() + EOL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-26 00:27:22
|
Revision: 7063 Author: victormote Date: 2006-04-25 17:27:11 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7063&view=rev Log Message: ----------- Change padding character to avoid problems with text editors. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFObject.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFObject.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFObject.java 2006-04-26 00:16:45 UTC (rev 7062) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFObject.java 2006-04-26 00:27:11 UTC (rev 7063) @@ -42,14 +42,18 @@ /** The String that should be used to end a line in the PDF document. */ public static final String EOL = "\n"; - /** The String that should be used to end a cross-reference line in the - * PDF document. The carriage-return is counter-intuitive but required. + /** + * The String that should be used to end a cross-reference line in the + * PDF document. * According to the PDF Reference, 3rd Edition, Section 3.4.3, each * cross-reference entry must be exactly 20 bytes long, including the - * end-of-line character(s). If newline is used for end-of-line, then an - * extra character must be padded. According to the Reference, that - * character must be either a space or a carriage-return. */ - public static final String XREF_EOL = "\r\n"; + * end-of-line character(s). + * If a 1-character eol is used (such as a newline), then an extra character + * must be padded. + * According to the Reference, that character must be a space. + * However, a space at the end of a line is often removed by editors, so we + * use a hyphen instead. */ + public static final String XREF_EOL = "-\n"; /** The String that should be used to end a line in log messages. */ public static final String MSG_EOL = "\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-26 00:16:53
|
Revision: 7062 Author: victormote Date: 2006-04-25 17:16:45 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7062&view=rev Log Message: ----------- 1. Fix structural problems. 2. Use CRLF line-ends. Modified Paths: -------------- trunk/foray/foray-pdf/resource/example/001.pdf Property Changed: ---------------- trunk/foray/foray-pdf/resource/example/001.pdf Modified: trunk/foray/foray-pdf/resource/example/001.pdf =================================================================== --- trunk/foray/foray-pdf/resource/example/001.pdf 2006-04-25 22:41:12 UTC (rev 7061) +++ trunk/foray/foray-pdf/resource/example/001.pdf 2006-04-26 00:16:45 UTC (rev 7062) @@ -1,63 +1,74 @@ -%PDF-1.4 -%\xAA\xAB\xAC\xAD -4 0 obj -<< -/Type /Info ->> -endobj -6 0 obj -<< /Length 24 >> -stream -BT -/F1 12 Tf -72 540 Td -(Hello World!) Tj -ET -endstream -endobj -7 0 obj -<< /Type /Page -/Parent 2 0 R -/MediaBox [ 0 0 396 612 ] -/Resources 3 0 R -/Contents 6 0 R ->> -endobj -2 0 obj -<< -/Type /Pages -/Count 1 -/Kids [ -7 0 R -] ->> -endobj -1 0 obj -<< -/Type /Catalog -/Pages 2 0 R ->> -endobj -3 0 obj -<< -/Font -<< -/F1 5 0 R ->> ->> -endobj -5 0 obj -<< -/Type /Font -/Subtype /Type1 -/BaseFont /Helvetica ->> -endobj -xref -trailer -<< -/Size 106 -/Root 1 0 R -/Info 4 0 R ->> -startxref +%PDF-1.4 +%\xAA\xAB\xAC\xAD +4 0 obj +<< +/Type /Info +>> +endobj +6 0 obj +<< /Length 49 >> +stream +BT +/F1 12 Tf +72 540 Td +(Hello World!) Tj +ET +endstream +endobj +7 0 obj +<< /Type /Page +/Parent 2 0 R +/MediaBox [ 0 0 396 612 ] +/Resources 3 0 R +/Contents 6 0 R +>> +endobj +2 0 obj +<< +/Type /Pages +/Count 1 +/Kids [ +7 0 R +] +>> +endobj +1 0 obj +<< +/Type /Catalog +/Pages 2 0 R +>> +endobj +3 0 obj +<< +/Font +<< +/F1 5 0 R +>> +>> +endobj +5 0 obj +<< +/Type /Font +/Subtype /Type1 +/BaseFont /Helvetica +>> +endobj +xref +0 8 +0000000000 65535 f +0000000340 00000 n +0000000272 00000 n +0000000395 00000 n +0000000017 00000 n +0000000446 00000 n +0000000055 00000 n +0000000158 00000 n +trailer +<< +/Size 2 +/Root 1 0 R +/Info 4 0 R +>> +startxref +523 +%%EOF Property changes on: trunk/foray/foray-pdf/resource/example/001.pdf ___________________________________________________________________ Name: svn:eol-style - native + CRLF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-25 22:41:18
|
Revision: 7061 Author: victormote Date: 2006-04-25 15:41:12 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7061&view=rev Log Message: ----------- First pass at batch file to run foray. Added Paths: ----------- trunk/foray/scripts/foray.bat Added: trunk/foray/scripts/foray.bat =================================================================== --- trunk/foray/scripts/foray.bat (rev 0) +++ trunk/foray/scripts/foray.bat 2006-04-25 22:41:12 UTC (rev 7061) @@ -0,0 +1,23 @@ +echo off + +set FORAY_CP=%FORAY_HOME%\build\foray-0.2b1.jar + +rem Add separate AXSL build in if it exists +set FORAY_CP=%FORAY_CP%;%AXSL_HOME%\build\ant\axsl-0.1a.jar + +rem Add ICU4J in (not in lib yet) +set FORAY_CP=%FORAY_CP%;D:\rsrc\icu4j\3_4_3\icu4j_3_4_3.jar + +rem Now add regular lib jar files +set FORAY_CP=%FORAY_CP%;%FORAY_HOME%\lib\avalon-framework-cvs-20020806.jar +set FORAY_CP=%FORAY_CP%;%FORAY_HOME%\lib\axsl-0.1a.jar +set FORAY_CP=%FORAY_CP%;%FORAY_HOME%\lib\batik.jar +set FORAY_CP=%FORAY_CP%;%FORAY_HOME%\lib\commons-logging.jar +set FORAY_CP=%FORAY_CP%;%FORAY_HOME%\lib\resolver.jar +set FORAY_CP=%FORAY_CP%;%FORAY_HOME%\lib\xercesImpl-2.7.1.jar + +java -Xmx256m -classpath "%FORAY_CP%" org.foray.app.FOray %1 %2 %3 %4 %5 %6 %7 %8 %9 + +set FORAY_CP= + +rem Last line of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-20 21:52:11
|
Revision: 7060 Author: victormote Date: 2006-04-20 14:52:02 -0700 (Thu, 20 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7060&view=rev Log Message: ----------- Set up a default context. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-20 21:46:36 UTC (rev 7059) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-20 21:52:02 UTC (rev 7060) @@ -480,10 +480,16 @@ */ public static void main(String[] args) { URL[] urlsToCompare = new URL[args.length]; + URL context = null; + try { + context = new URL("file", null, "."); + } catch (MalformedURLException e1) { + System.out.println("Unable to get URL context."); + } for (int i = 0; i < args.length; i++) { URL url = null; try { - url = new URL(args[i]); + url = new URL(context, args[i]); } catch (MalformedURLException e) { System.out.println("Malformed URL: " + args[i]); System.exit(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-20 21:46:41
|
Revision: 7059 Author: victormote Date: 2006-04-20 14:46:36 -0700 (Thu, 20 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7059&view=rev Log Message: ----------- Use different exit codes for various problems. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-20 21:45:08 UTC (rev 7058) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-20 21:46:36 UTC (rev 7059) @@ -495,10 +495,15 @@ boolean equivalent = processor.equivalent(); if (equivalent) { System.out.println("All XML Streams are equivalent."); + System.exit(0); + } else { + System.out.println("Differences(s) in XML Streams found."); + System.exit(3); } } catch (Exception e) { System.out.println("Error parsing input."); System.out.println(e.getMessage()); + System.exit(2); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-20 21:45:14
|
Revision: 7058 Author: victormote Date: 2006-04-20 14:45:08 -0700 (Thu, 20 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7058&view=rev Log Message: ----------- Use different exit codes for various problems. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-04-19 01:46:05 UTC (rev 7057) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-04-20 21:45:08 UTC (rev 7058) @@ -881,7 +881,7 @@ inputStream = new BufferedInputStream(fis); } catch (FileNotFoundException e) { System.err.println("File not found: " + input); - System.exit(1); + System.exit(2); } InputSource inputSource = new InputSource(inputStream); OutputStream outputStream = null; @@ -890,7 +890,7 @@ outputStream = new BufferedOutputStream(fos); } catch (FileNotFoundException e1) { System.err.println("File not found: " + output); - System.exit(1); + System.exit(3); } FOrayPretty processor = new FOrayPretty(inputSource, outputStream, catalog); @@ -899,6 +899,7 @@ } catch (Exception e) { System.out.print("Error parsing input."); e.printStackTrace(); + System.exit(4); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-19 01:46:15
|
Revision: 7057 Author: victormote Date: 2006-04-18 18:46:05 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7057&view=rev Log Message: ----------- Add document explaining the StAX license. Added Paths: ----------- trunk/foray/lib/stax.LICENSE.info.txt Added: trunk/foray/lib/stax.LICENSE.info.txt =================================================================== --- trunk/foray/lib/stax.LICENSE.info.txt (rev 0) +++ trunk/foray/lib/stax.LICENSE.info.txt 2006-04-19 01:46:05 UTC (rev 7057) @@ -0,0 +1,26 @@ +The StAX licensing is not as clear as one might hope. The most +straightforward explanation is found at this site: +http://www.xmlpull.org/impls.shtml + +As of April 18, 2006, the URL above stated the following: + +"There are multiple implementation of StAX API and you can chose an +implementation that best suites your need: from Reference +Implementation (RI) that is based on XPP under Apache License to +GPL-ed implementation: + * Reference Implementation (RI) at codehaus based on XPP3/MXP1 under + Apache 2.0 License +..." + +After the information above, additional implementations are listed. +As you can see, twice in the above statement the Reference +Implementation (the one used by FOray) is listed as being under an +Apache license. I have found no evidence to the contrary in any other +place. + +Another piece of evidence suggesting that StAX is suitable for +Apache-style work is that it has been incorporated into Java 6.0. + +Victor Mote, April 18, 2006 + +##### Last line of memo. ##### Property changes on: trunk/foray/lib/stax.LICENSE.info.txt ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-19 01:00:31
|
Revision: 7056 Author: victormote Date: 2006-04-18 18:00:26 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7056&view=rev Log Message: ----------- Make sure elements and attributes are equivalent. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 23:57:51 UTC (rev 7055) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-19 01:00:26 UTC (rev 7056) @@ -32,6 +32,7 @@ import java.net.MalformedURLException; import java.net.URL; +import javax.xml.namespace.QName; import javax.xml.stream.Location; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; @@ -133,6 +134,7 @@ int event = readEvents(); switch (event) { case XMLStreamConstants.START_DOCUMENT: { + /* Nothing to do here. */ break; } case XMLStreamConstants.END_DOCUMENT: { @@ -142,12 +144,18 @@ return true; } case XMLStreamConstants.START_ELEMENT: { - break; + if (this.compareElements()) { + break; + } + return false; } case XMLStreamConstants.END_ELEMENT: { + /* Nothing to do here. */ break; } case XMLStreamConstants.ATTRIBUTE: { + /* Ignore this. We will test all of the attributes at + * START_ELEMENT. */ break; } case XMLStreamConstants.CHARACTERS: { @@ -163,6 +171,8 @@ return false; } case XMLStreamConstants.SPACE: { + /* We should never get here as we ignore these in the + * parsing. */ break; } case XMLStreamConstants.COMMENT: { @@ -180,15 +190,19 @@ // case XMLStreamConstants.START_ENTITY: // case XMLStreamConstants.END_ENTITY: case XMLStreamConstants.ENTITY_DECLARATION: { + /* TODO: Not sure what to do here. */ break; } case XMLStreamConstants.ENTITY_REFERENCE: { + /* TODO: Not sure what to do here. */ break; } case XMLStreamConstants.NAMESPACE: { + /* TODO: Not sure what to do here. */ break; } case XMLStreamConstants.NOTATION_DECLARATION: { + /* TODO: Not sure what to do here. */ break; } case XMLStreamConstants.PROCESSING_INSTRUCTION: { @@ -351,26 +365,44 @@ return location.getLineNumber() + ":" + location.getColumnNumber(); } + /** + * @return True if all of the DTDs are equivalent. + */ private boolean compareDTD() { return compareStrings(); } + /** + * @return True if all of the Comments are equivalent. + */ private boolean compareComment() { return compareStrings(); } + /** + * @return True if all of the CDATA items are equivalent. + */ private boolean compareCDATA() { return compareStrings(); } + /** + * @return True if all of the Processing Instructions are equivalent. + */ private boolean compareProcessingInstruction() { return compareStrings(); } + /** + * @return True if all of the Character sequences are equivalent. + */ private boolean compareCharacters() { return compareStrings(); } + /** + * @return True if all of the Strings are equivalent. + */ private boolean compareStrings() { String baseString = this.readers[0].getText(); baseString = XMLUtil.normalizeWhitespace(baseString); @@ -390,6 +422,59 @@ } /** + * @return True if all of the Elements are equivalent. To be equivalent, + * they must have the same names, and must have exactly the same attributes + * and attribute values, although the attributes do not have to be in the + * same order. + */ + private boolean compareElements() { + /* 1. Make sure the names are the same. */ + QName baseElementName = this.readers[0].getName(); + for (int i = 1; i < this.readers.length; i++) { + QName compareElementName = this.readers[i].getName(); + if (! baseElementName.equals((compareElementName))) { + message("Document " + (i + 1) + " has different Element "); + return false; + } + } + /* 2. Make sure the attribute counts are the same. */ + int baseAttributeCount = this.readers[0].getAttributeCount(); + for (int i = 1; i < this.readers.length; i++) { + int compareAttributeCount = this.readers[i].getAttributeCount(); + if (baseAttributeCount != compareAttributeCount) { + message("Document " + (i + 1) + " has different Attribute " + + "Count "); + return false; + } + } + /* 3. Make sure that each attribute in first document exists in the + * others, and that their values are equal. */ + /* Iterate through each attribute of the base element. */ + for (int i = 0; i < baseAttributeCount; i++) { + QName baseAttributeName = this.readers[0].getAttributeName(i); + String baseAttributeValue = this.readers[0].getAttributeValue(i); + /* Iterate through each of the other documents. */ + for (int j = 1; j < this.readers.length; j++) { + XMLStreamReader reader = this.readers[j]; + String compareAttributeValue = reader.getAttributeValue( + baseAttributeName.getNamespaceURI(), + baseAttributeName.getLocalPart()); + if (compareAttributeValue == null) { + message("Attribute not found: " + + baseAttributeName.toString()); + return false; + } + if (! compareAttributeValue.equals(baseAttributeValue)) { + message("Attribute values differ: " + + baseAttributeName.toString()); + return false; + } + } + } + return true; + } + + /** * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 23:58:12
|
Revision: 7055 Author: victormote Date: 2006-04-18 16:57:51 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7055&view=rev Log Message: ----------- Move some common code to new XMLUtil class. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Added Paths: ----------- trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java Added: trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java (rev 0) +++ trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java 2006-04-18 23:57:51 UTC (rev 7055) @@ -0,0 +1,74 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.common; + +/** + * Utility class containing methods useful in parsing or building XML. + */ +public class XMLUtil { + + /** + * This class should never be instantiated. + */ + private XMLUtil() { } + + /** + * Converts all whitespace characters to spaces, then compresses all + * sequences of spaces to one space. + * @param input The String that should be converted. + * @return The converted String. + * @see #normalizeWhitespace(StringBuffer) + */ + public static String normalizeWhitespace(String input) { + StringBuffer buffer = new StringBuffer(input); + int changes = normalizeWhitespace(buffer); + if (changes < 1) { + return input; + } + return buffer.toString(); + } + + /** + * Converts all whitespace characters to spaces, then compresses all + * sequences of spaces to one space. + * @param buffer The StringBuffer that should be converted. + * @return The number of changes made to buffer. + * @see #normalizeWhitespace(String) + */ + public static int normalizeWhitespace(StringBuffer buffer) { + int changes = 0; + for (int i = 0; i < buffer.length(); i++) { + char c = buffer.charAt(i); + if (c != ' ' + && XMLCharacter.isXMLWhitespace(c)) { + buffer.setCharAt(i, ' '); + changes ++; + } + } + changes += StringUtil.replace(buffer, " ", " "); + return changes; + } + +} Property changes on: trunk/foray/foray-common/src/java/org/foray/common/XMLUtil.java ___________________________________________________________________ Name: svn:keywords + "Author Id Rev Date URL" Name: svn:eol-style + native Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-04-18 23:39:08 UTC (rev 7054) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-04-18 23:57:51 UTC (rev 7055) @@ -24,7 +24,7 @@ package org.foray.pretty; -import org.foray.common.StringUtil; +import org.foray.common.XMLUtil; import org.foray.pretty.dtd.DTD; import org.foray.pretty.dtd.DTDElement; import org.foray.pretty.dtd.ElementStack; @@ -393,7 +393,7 @@ ensureTopElementWritten(false); if (this.breakPCDATA) { /* Note: SAX input has linefeeds normalized to \n. */ - normalizeWhitespace(); + XMLUtil.normalizeWhitespace(this.charBuffer); this.queue.add(this.charBuffer.toString()); } else { writeRawPCDATA(this.charBuffer.toString()); @@ -401,15 +401,6 @@ this.charBuffer.setLength(0); } - private void normalizeWhitespace() { - /* Convert all line-feeds to spaces. */ - StringUtil.replace(this.charBuffer, "\n", " "); - /* Convert all tabs to spaces. */ - StringUtil.replace(this.charBuffer, "\t", " "); - /* Remove extra spaces. */ - StringUtil.replace(this.charBuffer, " ", " "); - } - private void addToQueue(String string) { if (string == null) { return; Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 23:39:08 UTC (rev 7054) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 23:57:51 UTC (rev 7055) @@ -25,7 +25,7 @@ package org.foray.pretty; import org.foray.common.StringUtil; -import org.foray.common.XMLCharacter; +import org.foray.common.XMLUtil; import java.io.IOException; import java.io.InputStream; @@ -373,10 +373,10 @@ private boolean compareStrings() { String baseString = this.readers[0].getText(); - baseString = normalizeWhitespace(baseString); + baseString = XMLUtil.normalizeWhitespace(baseString); for (int i = 1; i < this.readers.length; i++) { String compareString = this.readers[i].getText(); - compareString = normalizeWhitespace(compareString); + compareString = XMLUtil.normalizeWhitespace(compareString); int differIndex = StringUtil.firstDifferent(baseString, compareString); if (differIndex < 0) { @@ -390,30 +390,6 @@ } /** - * Converts all whitespace characters to spaces, then compresses all - * sequences of spaces to one space. - * @param input The String that should be converted. - * @return The converted String. - */ - private String normalizeWhitespace(String input) { - int changes = 0; - StringBuffer buffer = new StringBuffer(input); - for (int i = 0; i < buffer.length(); i++) { - char c = buffer.charAt(i); - if (c != ' ' - && XMLCharacter.isXMLWhitespace(c)) { - buffer.setCharAt(i, ' '); - changes ++; - } - } - changes += StringUtil.replace(buffer, " ", " "); - if (changes < 1) { - return input; - } - return buffer.toString(); - } - - /** * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 23:39:15
|
Revision: 7054 Author: victormote Date: 2006-04-18 16:39:08 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7054&view=rev Log Message: ----------- Use new standard Common method. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-04-18 23:38:34 UTC (rev 7053) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-04-18 23:39:08 UTC (rev 7054) @@ -24,6 +24,7 @@ package org.foray.pretty; +import org.foray.common.StringUtil; import org.foray.pretty.dtd.DTD; import org.foray.pretty.dtd.DTDElement; import org.foray.pretty.dtd.ElementStack; @@ -402,29 +403,13 @@ private void normalizeWhitespace() { /* Convert all line-feeds to spaces. */ - convertString(this.charBuffer, "\n", " "); + StringUtil.replace(this.charBuffer, "\n", " "); /* Convert all tabs to spaces. */ - convertString(this.charBuffer, "\t", " "); + StringUtil.replace(this.charBuffer, "\t", " "); /* Remove extra spaces. */ - convertString(this.charBuffer, " ", " "); + StringUtil.replace(this.charBuffer, " ", " "); } - /** - * Replaces all occurrences of a given String with a different Strings. - */ - private static void convertString(StringBuffer buffer, String oldString, - String newString) { - boolean anyChanges = true; - while (anyChanges) { - anyChanges = false; - int index = buffer.indexOf(oldString); - if (index > -1) { - buffer.replace(index, index + oldString.length(), newString); - anyChanges = true; - } - } - } - private void addToQueue(String string) { if (string == null) { return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 23:38:38
|
Revision: 7053 Author: victormote Date: 2006-04-18 16:38:34 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7053&view=rev Log Message: ----------- Include Common in build script. Modified Paths: -------------- trunk/foray/foray-pretty/scripts/build.xml Modified: trunk/foray/foray-pretty/scripts/build.xml =================================================================== --- trunk/foray/foray-pretty/scripts/build.xml 2006-04-18 23:37:59 UTC (rev 7052) +++ trunk/foray/foray-pretty/scripts/build.xml 2006-04-18 23:38:34 UTC (rev 7053) @@ -39,6 +39,9 @@ <include name="resolver*.jar"/> <include name="xercesImpl*.jar"/> </fileset> + <fileset dir="${foray.home}/foray-common/build/ant"> + <include name="*.jar"/> + </fileset> </path> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 23:38:06
|
Revision: 7052 Author: victormote Date: 2006-04-18 16:37:59 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7052&view=rev Log Message: ----------- Build Common before Pretty. Modified Paths: -------------- trunk/foray/scripts/build.xml Modified: trunk/foray/scripts/build.xml =================================================================== --- trunk/foray/scripts/build.xml 2006-04-18 23:27:41 UTC (rev 7051) +++ trunk/foray/scripts/build.xml 2006-04-18 23:37:59 UTC (rev 7052) @@ -69,13 +69,13 @@ <target name="subpackages" depends="prepare"> <echo message="Building the Subpackages"/> - <ant antfile="${foray.home}/foray-pretty/scripts/build.xml" + <ant antfile="${foray.home}/foray-common/scripts/build.xml" inheritall="false" target="package"> <property name="foray.config" value="${foray.config}"/> </ant> - <ant antfile="${foray.home}/foray-common/scripts/build.xml" + <ant antfile="${foray.home}/foray-pretty/scripts/build.xml" inheritall="false" target="package"> <property name="foray.config" value="${foray.config}"/> @@ -166,14 +166,14 @@ <format property="ts" pattern="yyyyMMdd-HHmmss-z"/> </tstamp> + <fileset id="foray-common-classes" + dir="${foray.home}/foray-common/build/ant/classes"> + <include name="**"/> + </fileset> <fileset id="foray-pretty-classes" dir="${foray.home}/foray-pretty/build/ant/classes"> <include name="**"/> </fileset> - <fileset id="foray-common-classes" - dir="${foray.home}/foray-common/build/ant/classes"> - <include name="**"/> - </fileset> <fileset id="foray-graphic-classes" dir="${foray.home}/foray-graphic/build/ant/classes"> <include name="**"/> @@ -229,8 +229,8 @@ <echo message="Creating the jar file ${app.jar.name}"/> <jar jarfile="${app.jar.path}"> + <fileset refid="foray-common-classes"/> <fileset refid="foray-pretty-classes"/> - <fileset refid="foray-common-classes"/> <fileset refid="foray-graphic-classes"/> <fileset refid="foray-mif-classes"/> <fileset refid="foray-ps-classes"/> @@ -384,10 +384,6 @@ <package name="org.foray.demo"/> <package name="org.foray.demo.*"/> </group> - <group title="The FOray Pretty Module"> - <package name="org.foray.pretty"/> - <package name="org.foray.pretty.*"/> - </group> <group title="The FOray Common Module"> <package name="org.foray.common"/> <package name="org.foray.common.*"/> @@ -436,6 +432,10 @@ <package name="org.foray.render"/> <package name="org.foray.render.*"/> </group> + <group title="The FOray Pretty Module"> + <package name="org.foray.pretty"/> + <package name="org.foray.pretty.*"/> + </group> </javadoc> </target> @@ -446,11 +446,11 @@ <target name="clean" depends="init" description="Cleans the build directory"> <delete dir="${build.dir}"/> - <ant antfile="${foray.home}/foray-pretty/scripts/build.xml" + <ant antfile="${foray.home}/foray-common/scripts/build.xml" inheritall="false" target="clean"/> - <ant antfile="${foray.home}/foray-common/scripts/build.xml" + <ant antfile="${foray.home}/foray-pretty/scripts/build.xml" inheritall="false" target="clean"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 23:27:48
|
Revision: 7051 Author: victormote Date: 2006-04-18 16:27:41 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7051&view=rev Log Message: ----------- Text-handling improvements. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 23:27:13 UTC (rev 7050) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 23:27:41 UTC (rev 7051) @@ -25,6 +25,7 @@ package org.foray.pretty; import org.foray.common.StringUtil; +import org.foray.common.XMLCharacter; import java.io.IOException; import java.io.InputStream; @@ -150,16 +151,25 @@ break; } case XMLStreamConstants.CHARACTERS: { - break; + if (this.compareCharacters()) { + break; + } + return false; } case XMLStreamConstants.CDATA: { - break; + if (this.compareCDATA()) { + break; + } + return false; } case XMLStreamConstants.SPACE: { break; } case XMLStreamConstants.COMMENT: { - break; + if (this.compareComment()) { + break; + } + return false; } case XMLStreamConstants.DTD: { if (this.compareDTD()) { @@ -182,7 +192,10 @@ break; } case XMLStreamConstants.PROCESSING_INSTRUCTION: { - break; + if (this.compareProcessingInstruction()) { + break; + } + return false; } case Integer.MIN_VALUE: { /* This means that the events were not equal between the @@ -342,10 +355,28 @@ return compareStrings(); } + private boolean compareComment() { + return compareStrings(); + } + + private boolean compareCDATA() { + return compareStrings(); + } + + private boolean compareProcessingInstruction() { + return compareStrings(); + } + + private boolean compareCharacters() { + return compareStrings(); + } + private boolean compareStrings() { String baseString = this.readers[0].getText(); + baseString = normalizeWhitespace(baseString); for (int i = 1; i < this.readers.length; i++) { String compareString = this.readers[i].getText(); + compareString = normalizeWhitespace(compareString); int differIndex = StringUtil.firstDifferent(baseString, compareString); if (differIndex < 0) { @@ -359,6 +390,30 @@ } /** + * Converts all whitespace characters to spaces, then compresses all + * sequences of spaces to one space. + * @param input The String that should be converted. + * @return The converted String. + */ + private String normalizeWhitespace(String input) { + int changes = 0; + StringBuffer buffer = new StringBuffer(input); + for (int i = 0; i < buffer.length(); i++) { + char c = buffer.charAt(i); + if (c != ' ' + && XMLCharacter.isXMLWhitespace(c)) { + buffer.setCharAt(i, ' '); + changes ++; + } + } + changes += StringUtil.replace(buffer, " ", " "); + if (changes < 1) { + return input; + } + return buffer.toString(); + } + + /** * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 23:27:18
|
Revision: 7050 Author: victormote Date: 2006-04-18 16:27:13 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7050&view=rev Log Message: ----------- Add method for simple text replacement. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java Modified: trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java 2006-04-18 22:41:50 UTC (rev 7049) +++ trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java 2006-04-18 23:27:13 UTC (rev 7050) @@ -302,4 +302,27 @@ return chars1.length; } + /** + * Replaces all occurrences of a given substring with a different substring. + * @param buffer The SringBuffer in which the replacement should occur. + * @param oldString The substring to be replaced by newString. + * @param newString The substring that should replace oldString. + * @return The number of replacements that were made. + */ + public static int replace(StringBuffer buffer, String oldString, + String newString) { + int numChanges = 0; + boolean anyChanges = true; + while (anyChanges) { + anyChanges = false; + int index = buffer.indexOf(oldString); + if (index > -1) { + buffer.replace(index, index + oldString.length(), newString); + anyChanges = true; + numChanges ++; + } + } + return numChanges; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 22:41:57
|
Revision: 7049 Author: victormote Date: 2006-04-18 15:41:50 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7049&view=rev Log Message: ----------- Improvements to String comparisons. Modified Paths: -------------- trunk/foray/foray-pretty/.classpath trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/.classpath =================================================================== --- trunk/foray/foray-pretty/.classpath 2006-04-18 22:10:19 UTC (rev 7048) +++ trunk/foray/foray-pretty/.classpath 2006-04-18 22:41:50 UTC (rev 7049) @@ -7,5 +7,6 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/xml-apis-1.3.02.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/stax-api-1.0.1.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/stax-1.2.0_rc2-dev.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 22:10:19 UTC (rev 7048) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 22:41:50 UTC (rev 7049) @@ -24,6 +24,8 @@ package org.foray.pretty; +import org.foray.common.StringUtil; + import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -160,7 +162,10 @@ break; } case XMLStreamConstants.DTD: { - break; + if (this.compareDTD()) { + break; + } + return false; } // case XMLStreamConstants.START_ENTITY: // case XMLStreamConstants.END_ENTITY: @@ -333,6 +338,26 @@ return location.getLineNumber() + ":" + location.getColumnNumber(); } + private boolean compareDTD() { + return compareStrings(); + } + + private boolean compareStrings() { + String baseString = this.readers[0].getText(); + for (int i = 1; i < this.readers.length; i++) { + String compareString = this.readers[i].getText(); + int differIndex = StringUtil.firstDifferent(baseString, + compareString); + if (differIndex < 0) { + return true; + } + message("Document " + (i + 1) + " differs at character " + + (differIndex + 1)); + return false; + } + return true; + } + /** * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 22:10:24
|
Revision: 7048 Author: victormote Date: 2006-04-18 15:10:19 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7048&view=rev Log Message: ----------- Add method that tells where two Strings differ. Modified Paths: -------------- trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java Modified: trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java =================================================================== --- trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java 2006-04-18 21:25:02 UTC (rev 7047) +++ trunk/foray/foray-common/src/java/org/foray/common/StringUtil.java 2006-04-18 22:10:19 UTC (rev 7048) @@ -274,4 +274,32 @@ return output; } + /** + * Compares two Strings for equality, returning the index to the first + * different character. + * @param string1 The first String being compared. + * @param string2 The second String being compared. + * @return The index to the first character in the Strings that is + * different. If the Strings are identical, returns -1. + */ + public static int firstDifferent(String string1, String string2) { + if (string2.equals(string1)) { + return -1; + } + char[] chars1 = string1.toCharArray(); + char[] chars2 = string2.toCharArray(); + for (int i = 0; i < chars1.length; i++) { + if (i >= chars2.length) { + return i; + } + if (chars1[i] != chars2[i]) { + return i; + } + } + /* If we got all the way through chars1 with no differences, then + * chars2 is longer than chars1, and the first different character is + * therefore the first character after the last character of chars1. */ + return chars1.length; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 21:25:09
|
Revision: 7047 Author: victormote Date: 2006-04-18 14:25:02 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7047&view=rev Log Message: ----------- Try to handle whitespace. Not sure this is right as DTD is not used. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 20:35:46 UTC (rev 7046) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 21:25:02 UTC (rev 7047) @@ -53,6 +53,12 @@ */ private String[] readerIDs; + /* Begin configurable parameters. */ + /** Ignores character items that are all whitespace. */ + boolean ignoreCharacterWhitespace = true; + + /* End configurable parameters. */ + /** * Constructor accepting URLs to compare. * @see #FOrayXDiff(InputStream[]) For a constructor that takes any @@ -95,6 +101,8 @@ } this.readers = new XMLStreamReader[streams.length]; XMLInputFactory factory = XMLInputFactory.newInstance(); + /* Make parsers coalesce adjacent character data. */ + factory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE); factory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE); for (int i = 0; i < streams.length; i++) { @@ -174,7 +182,6 @@ case Integer.MIN_VALUE: { /* This means that the events were not equal between the * documents. */ - message("Difference in Events"); return false; } default: { @@ -194,27 +201,114 @@ private int readEvents() throws XMLStreamException { int[] events = new int[this.readers.length]; for (int i = 0; i < this.readers.length; i++) { - if (! this.readers[i].hasNext()) { - events[i] = XMLStreamReader.END_DOCUMENT; - } else { - events[i] = this.readers[i].next(); - } + events[i] = readEvent(i); } int baseEventValue = events[0]; for (int i = 1; i < events.length; i++) { if (events[i] != baseEventValue) { + message("Difference in Events\n" + + " Document 1: " + getEventDescription(baseEventValue) + + "\n" + + " Document " + (i + 1) + ": " + + getEventDescription(events[i])); return Integer.MIN_VALUE; } } return baseEventValue; } + public static String getEventDescription(int event) { + switch (event) { + case XMLStreamConstants.START_DOCUMENT: { + return "Start Document"; + } + case XMLStreamConstants.END_DOCUMENT: { + return "End Document"; + } + case XMLStreamConstants.START_ELEMENT: { + return "Start Element"; + } + case XMLStreamConstants.END_ELEMENT: { + return "End Element"; + } + case XMLStreamConstants.ATTRIBUTE: { + return "Attribute"; + } + case XMLStreamConstants.CHARACTERS: { + return "Characters"; + } + case XMLStreamConstants.CDATA: { + return "CDATA"; + } + case XMLStreamConstants.SPACE: { + return "Ignorable Whitespace"; + } + case XMLStreamConstants.COMMENT: { + return "Comment"; + } + case XMLStreamConstants.DTD: { + return "DTD"; + } +// case XMLStreamConstants.START_ENTITY: +// case XMLStreamConstants.END_ENTITY: + case XMLStreamConstants.ENTITY_DECLARATION: { + return "Entity Declaration"; + } + case XMLStreamConstants.ENTITY_REFERENCE: { + return "Entity Reference"; + } + case XMLStreamConstants.NAMESPACE: { + return "Namespace"; + } + case XMLStreamConstants.NOTATION_DECLARATION: { + return "Notation Declaration"; + } + case XMLStreamConstants.PROCESSING_INSTRUCTION: { + return "Processing Instruction"; + } + default: { + return "Unknown"; + } + } + } + + /** + * @param i + * @throws XMLStreamException + */ + private int readEvent(int i) throws XMLStreamException { + XMLStreamReader reader = this.readers[i]; + if (! reader.hasNext()) { + return XMLStreamReader.END_DOCUMENT; + } + boolean done = false; + int event = Integer.MIN_VALUE; + while (! done) { + event = this.readers[i].next(); + boolean isInteresting = true; + if (event == XMLStreamReader.SPACE) { + isInteresting = false; + } + if (this.ignoreCharacterWhitespace) { + if (event == XMLStreamReader.CHARACTERS + && reader.isWhiteSpace()) { + isInteresting = false; + } + } + if (isInteresting) { + done = true; + } + } + return event; + } + private void message(String message) { System.out.println(message); for (int i = 0; i < this.readers.length; i++) { String sourceDescription = getSourceDescription(i); String sourceLocation = getSourceLocation(i); - System.out.println(" " + sourceDescription + ":" + sourceLocation); + System.out.println(" Document " + (i + 1) + ": " + + sourceDescription + ":" + sourceLocation); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 20:35:51
|
Revision: 7046 Author: victormote Date: 2006-04-18 13:35:46 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7046&view=rev Log Message: ----------- Improvements in user messages. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 19:44:19 UTC (rev 7045) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 20:35:46 UTC (rev 7046) @@ -29,6 +29,7 @@ import java.net.MalformedURLException; import java.net.URL; +import javax.xml.stream.Location; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; @@ -46,6 +47,12 @@ private XMLStreamReader[] readers; + /** Caches the best description that we can find of the input source for + * each of the items in {@link #readers}. The Location instances provided + * don't provide this information, so we work around that limitation here. + */ + private String[] readerIDs; + /** * Constructor accepting URLs to compare. * @see #FOrayXDiff(InputStream[]) For a constructor that takes any @@ -56,9 +63,13 @@ throw new Exception("No URLs to compare."); } InputStream[] streams = new InputStream[urls.length]; + if (readerIDs == null) { + readerIDs = new String[urls.length]; + } for (int i = 0; i < urls.length; i++) { InputStream in = urls[i].openStream(); streams[i] = in; + this.readerIDs[i] = urls[i].toExternalForm(); } convertStreams(streams); } @@ -67,6 +78,9 @@ * Constructor accepting InputStreams to compare. */ public FOrayXDiff(InputStream[] streams) throws Exception { + if (readerIDs == null) { + readerIDs = new String[streams.length]; + } convertStreams(streams); } @@ -81,9 +95,16 @@ } this.readers = new XMLStreamReader[streams.length]; XMLInputFactory factory = XMLInputFactory.newInstance(); + factory.setProperty("javax.xml.stream.isReplacingEntityReferences", + Boolean.FALSE); for (int i = 0; i < streams.length; i++) { InputStream in = streams[i]; this.readers[i] = factory.createXMLStreamReader(in); + if (this.readerIDs[i] == null) { + /* If this stream was created from a URL, this should already + * be filled in. Otherwise, we'll do the best we can here. */ + this.readerIDs[i] = in.toString(); + } } } @@ -153,6 +174,7 @@ case Integer.MIN_VALUE: { /* This means that the events were not equal between the * documents. */ + message("Difference in Events"); return false; } default: { @@ -187,6 +209,36 @@ return baseEventValue; } + private void message(String message) { + System.out.println(message); + for (int i = 0; i < this.readers.length; i++) { + String sourceDescription = getSourceDescription(i); + String sourceLocation = getSourceLocation(i); + System.out.println(" " + sourceDescription + ":" + sourceLocation); + } + } + + private String getSourceDescription(int inputIndex) { + Location location = this.readers[inputIndex].getLocation(); + if (location != null + && location.getSystemId() != null) { + return location.getSystemId(); + } + if (location != null + && location.getPublicId() != null) { + return location.getPublicId(); + } + return this.readerIDs[inputIndex]; + } + + private String getSourceLocation(int inputIndex) { + Location location = this.readers[inputIndex].getLocation(); + if (location == null) { + return "Unknown"; + } + return location.getLineNumber() + ":" + location.getColumnNumber(); + } + /** * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 19:44:23
|
Revision: 7045 Author: victormote Date: 2006-04-18 12:44:19 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7045&view=rev Log Message: ----------- Fix NPE. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 19:37:30 UTC (rev 7044) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 19:44:19 UTC (rev 7045) @@ -75,6 +75,11 @@ if (streams == null) { throw new IllegalArgumentException("No InputStreams to compare."); } + if (streams.length < 2) { + throw new IllegalArgumentException("At least two XML Streams are " + + "needed for comparison."); + } + this.readers = new XMLStreamReader[streams.length]; XMLInputFactory factory = XMLInputFactory.newInstance(); for (int i = 0; i < streams.length; i++) { InputStream in = streams[i]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 19:37:38
|
Revision: 7044 Author: victormote Date: 2006-04-18 12:37:30 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7044&view=rev Log Message: ----------- Add path to the stax implementation. Modified Paths: -------------- trunk/foray/foray-pretty/.classpath Modified: trunk/foray/foray-pretty/.classpath =================================================================== --- trunk/foray/foray-pretty/.classpath 2006-04-18 18:45:41 UTC (rev 7043) +++ trunk/foray/foray-pretty/.classpath 2006-04-18 19:37:30 UTC (rev 7044) @@ -6,5 +6,6 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/resolver.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/xml-apis-1.3.02.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/stax-api-1.0.1.jar"/> + <classpathentry kind="var" path="FORAY_LIB_ROOT/stax-1.2.0_rc2-dev.jar"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 18:45:46
|
Revision: 7043 Author: victormote Date: 2006-04-18 11:45:41 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7043&view=rev Log Message: ----------- Add rough outline of the event processing. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 13:40:26 UTC (rev 7042) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 18:45:41 UTC (rev 7043) @@ -30,6 +30,7 @@ import java.net.URL; import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -81,10 +82,107 @@ } } - public void compare() throws IOException, XMLStreamException { + /** + * Compares the XML streams passed or implicitly passed in the constructor, + * and returns true if the streams are equivalent, false if there is one or + * more differences. + * @return True if the streams are equivalent, false if there is one or + * more differences. + * @throws IOException + * @throws XMLStreamException + */ + public boolean equivalent() throws IOException, XMLStreamException { + while (true) { + int event = readEvents(); + switch (event) { + case XMLStreamConstants.START_DOCUMENT: { + break; + } + case XMLStreamConstants.END_DOCUMENT: { + /* We have read the entire document. If there were any + * differences, we would have found them by now. We did not. + * Therefore all documents are equivalent. */ + return true; + } + case XMLStreamConstants.START_ELEMENT: { + break; + } + case XMLStreamConstants.END_ELEMENT: { + break; + } + case XMLStreamConstants.ATTRIBUTE: { + break; + } + case XMLStreamConstants.CHARACTERS: { + break; + } + case XMLStreamConstants.CDATA: { + break; + } + case XMLStreamConstants.SPACE: { + break; + } + case XMLStreamConstants.COMMENT: { + break; + } + case XMLStreamConstants.DTD: { + break; + } +// case XMLStreamConstants.START_ENTITY: +// case XMLStreamConstants.END_ENTITY: + case XMLStreamConstants.ENTITY_DECLARATION: { + break; + } + case XMLStreamConstants.ENTITY_REFERENCE: { + break; + } + case XMLStreamConstants.NAMESPACE: { + break; + } + case XMLStreamConstants.NOTATION_DECLARATION: { + break; + } + case XMLStreamConstants.PROCESSING_INSTRUCTION: { + break; + } + case Integer.MIN_VALUE: { + /* This means that the events were not equal between the + * documents. */ + return false; + } + default: { + throw new XMLStreamException("Unknown Event: " + event); + } + } + } } /** + * Checks the event type for all XMLStreamReaders for equality, returning + * the value if all are equal. + * @return If the events are equal, returns that value. Otherwise, returns + * {@link Integer#MIN_VALUE}. + * @throws XMLStreamException + */ + private int readEvents() throws XMLStreamException { + int[] events = new int[this.readers.length]; + for (int i = 0; i < this.readers.length; i++) { + if (! this.readers[i].hasNext()) { + events[i] = XMLStreamReader.END_DOCUMENT; + } else { + events[i] = this.readers[i].next(); + } + } + int baseEventValue = events[0]; + for (int i = 1; i < events.length; i++) { + if (events[i] != baseEventValue) { + return Integer.MIN_VALUE; + } + } + return baseEventValue; + } + + /** * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. */ @@ -102,7 +200,10 @@ } try { FOrayXDiff processor = new FOrayXDiff(urlsToCompare); - processor.compare(); + boolean equivalent = processor.equivalent(); + if (equivalent) { + System.out.println("All XML Streams are equivalent."); + } } catch (Exception e) { System.out.println("Error parsing input."); System.out.println(e.getMessage()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-18 13:40:52
|
Revision: 7042 Author: victormote Date: 2006-04-18 06:40:26 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7042&view=rev Log Message: ----------- 1. Add Stax pull-parsing libs and update FOrayPretty to have access to them. 2. Convert the FOrayXDiff class to use pull-parsing. Modified Paths: -------------- trunk/foray/foray-pretty/.classpath trunk/foray/foray-pretty/scripts/build.xml trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Added Paths: ----------- trunk/foray/lib/stax-1.2.0_rc2-dev.jar trunk/foray/lib/stax-api-1.0.1.jar Modified: trunk/foray/foray-pretty/.classpath =================================================================== --- trunk/foray/foray-pretty/.classpath 2006-04-15 22:24:24 UTC (rev 7041) +++ trunk/foray/foray-pretty/.classpath 2006-04-18 13:40:26 UTC (rev 7042) @@ -5,5 +5,6 @@ <classpathentry kind="var" path="FORAY_LIB_ROOT/xercesImpl-2.7.1.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/resolver.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/xml-apis-1.3.02.jar"/> + <classpathentry kind="var" path="FORAY_LIB_ROOT/stax-api-1.0.1.jar"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-pretty/scripts/build.xml =================================================================== --- trunk/foray/foray-pretty/scripts/build.xml 2006-04-15 22:24:24 UTC (rev 7041) +++ trunk/foray/foray-pretty/scripts/build.xml 2006-04-18 13:40:26 UTC (rev 7042) @@ -35,11 +35,8 @@ </fileset> <fileset dir="${lib.dir}"> <include name="xml-apis*.jar"/> - </fileset> - <fileset dir="${lib.dir}"> + <include name="stax*.jar"/> <include name="resolver*.jar"/> - </fileset> - <fileset dir="${lib.dir}"> <include name="xercesImpl*.jar"/> </fileset> </path> Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-15 22:24:24 UTC (rev 7041) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-04-18 13:40:26 UTC (rev 7042) @@ -24,358 +24,88 @@ package org.foray.pretty; -import org.foray.pretty.dtd.DTD; -import org.foray.pretty.dtd.DTDElement; -import org.foray.pretty.dtd.ElementStack; - -import org.apache.xerces.util.XMLCatalogResolver; - -import org.xml.sax.Attributes; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.XMLReader; -import org.xml.sax.ext.DefaultHandler2; -import org.xml.sax.helpers.AttributesImpl; - -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; /** - * Command-line application that reads two XML files and finds the first - * difference (if any) between them. + * This class reads two or more XML streams and finds the first difference (if + * any) between them. * This is not intended to be a general-purpose XML diff and compare tool. * It is suitable in situations where some tranformation (like a pretty-print) * has taken place and we wish to make sure that no significant changes were * made to the document. */ -public class FOrayXDiff extends DefaultHandler2 { +public class FOrayXDiff { - /** The base document to be compared. */ - private XDiffDocument doc1; + private XMLStreamReader[] readers; - /** The second document to be compared. */ - private XDiffDocument doc2; - - /* Begin configuration variables. TODO: These need to be externalized and - * exposed with setters. */ - /** - * Set this to true if PCDATA content can have space characters replaced - * by line terminators and vice versa. + * Constructor accepting URLs to compare. + * @see #FOrayXDiff(InputStream[]) For a constructor that takes any + * {@link InputStream}. */ - private boolean breakPCDATA = true; - - /* End configuration variables. */ - - /** - * Constructor. - */ - public FOrayXDiff(InputSource inputSource1, InputSource inputSource2, - String catalog) { - this.doc1 = new XDiffDocument(inputSource1, catalog); - this.doc2 = new XDiffDocument(inputSource2, catalog); - } - - public void start() { - try { - this.doc1.start(); - } catch (Exception e) { - this.logError("Unable to parse:\n " + doc1.input); + public FOrayXDiff(URL[] urls) throws Exception { + if (urls == null) { + throw new Exception("No URLs to compare."); } - try { - this.doc2.start(); - } catch (Exception e) { - this.logError("Unable to parse:\n " + doc2.input); + InputStream[] streams = new InputStream[urls.length]; + for (int i = 0; i < urls.length; i++) { + InputStream in = urls[i].openStream(); + streams[i] = in; } + convertStreams(streams); } - private void cleanup() { - } - /** - * Replaces all occurrences of a given String with a different Strings. + * Constructor accepting InputStreams to compare. */ - private static void convertString(StringBuffer buffer, String oldString, - String newString) { - boolean anyChanges = true; - while (anyChanges) { - anyChanges = false; - int index = buffer.indexOf(oldString); - if (index > -1) { - buffer.replace(index, index + oldString.length(), newString); - anyChanges = true; - } - } + public FOrayXDiff(InputStream[] streams) throws Exception { + convertStreams(streams); } - public EntityResolver getEntityResolver(String catalog) { - if (catalog == null) { - return null; + private void convertStreams(InputStream[] streams) + throws IllegalArgumentException, XMLStreamException { + if (streams == null) { + throw new IllegalArgumentException("No InputStreams to compare."); } - String [] catalogs = {catalog}; - XMLCatalogResolver resolver = new XMLCatalogResolver(); - resolver.setPreferPublic(true); - resolver.setCatalogList(catalogs); - return resolver; + XMLInputFactory factory = XMLInputFactory.newInstance(); + for (int i = 0; i < streams.length; i++) { + InputStream in = streams[i]; + this.readers[i] = factory.createXMLStreamReader(in); + } } - private void logError(String message) { - Locator locator1 = this.doc1.getDocumentLocator(); - Locator locator2 = this.doc2.getDocumentLocator(); - if (locator1 != null) { - System.out.println(locator1.getSystemId() + ":" - + locator1.getLineNumber() + ":" - + locator1.getColumnNumber()); - } - if (locator2 != null) { - System.out.println(locator2.getSystemId() + ":" - + locator2.getLineNumber() + ":" - + locator2.getColumnNumber()); - } - System.out.println(message); + public void compare() throws IOException, XMLStreamException { } /** - * Private inner class representing an XML document that is part of the - * comparison. + * Command-line interface for {@link FOrayXDiff}. + * @param args Two or more URLs that should be compared. */ - private class XDiffDocument extends DefaultHandler2 { - - InputSource input; - - private Locator locator; - - private ElementStack elementStack = new ElementStack(); - - private DTD dtd = new DTD(); - - private StringBuffer charBuffer = new StringBuffer(); - - private EntityResolver entityResolver; - - /* Begin state variables. */ - - /** State variable tracking whether we are currently inside the DTD or - * not. */ - private boolean inDTD = false; - - /** State variable tracking whether we are currently inside an entity - * expansion or not. */ - private boolean inEntity = false; - - /* End state variables. */ - - XDiffDocument(InputSource input, String catalog) { - this.input = input; - this.entityResolver = getEntityResolver(catalog); - } - - /** - * Intantiates parser and starts parsing of input. - */ - public void start() throws IOException, SAXException, - ParserConfigurationException { - XMLReader parser = createParser(); - - /* Bind the LexicalHandler to the XMLReader if possible. */ + public static void main(String[] args) { + URL[] urlsToCompare = new URL[args.length]; + for (int i = 0; i < args.length; i++) { + URL url = null; try { - parser.setProperty("http://xml.org/sax/properties/lexical-handler", - this); - } catch (SAXNotSupportedException e1) { - logError("Parser does not support LexicalHandler."); + url = new URL(args[i]); + } catch (MalformedURLException e) { + System.out.println("Malformed URL: " + args[i]); + System.exit(1); } - - /* Bind the DeclHandler to the XMLReader if possible. */ - try { - parser.setProperty("http://xml.org/sax/properties/declaration-handler", - this); - } catch (SAXNotSupportedException e) { - logError("Parser does not support Declaration Handler."); - } - - /* Turn on validation if it is available. */ - try { - parser.setFeature("http://xml.org/sax/features/validation", true); - } catch (SAXNotRecognizedException e1) { - logError("Parser does not recognize validation."); - } catch (SAXNotSupportedException e1) { - logError("Parser unable to validate."); - } - parser.setContentHandler(this); - parser.parse(this.input); - cleanup(); + urlsToCompare[i] = url; } - - /** - * creates a SAX parser - * - * @return the created SAX parser - */ - public XMLReader createParser() throws SAXException, - ParserConfigurationException { - SAXParserFactory spf = - javax.xml.parsers.SAXParserFactory.newInstance(); - spf.setNamespaceAware(true); - XMLReader xmlReader = spf.newSAXParser().getXMLReader(); - if (this.entityResolver != null) { - xmlReader.setEntityResolver(this.entityResolver); - } - return xmlReader; - } - - public void setDocumentLocator(Locator locator) { - this.locator = locator; - } - - public Locator getDocumentLocator() { - return this.locator; - } - - public void startDocument() { - } - - public void endDocument() { - } - - public void startElement(String uri, String local, String qName, - Attributes attributes) { - flushCharacters(); - /* Must copy the attributes as they are reset on each callback. */ - Attributes attributesCache = new AttributesImpl(attributes); - if (attributesCache == null) { - attributesCache = null; - } - DTDElement element = this.dtd.getElement(local); - this.elementStack.push(element); - } - - public void endElement(String uri, String local, String qName) { - flushCharacters(); - } - - public void characters(char[] buffer, int offset, int length) { - if (this.inEntity) { - /* Skip these characters. We are writing the unexpanded entity - * elsewhere. We do not want to also write the expanded version. */ - return; - } - this.charBuffer.append(buffer, offset, length); - } - - public void processingInstruction(String target, String data) { - } - - public void ignorableWhitespace(char[] buffer, int offset, int length) { - /* Ignorable white space is just ignored. */ - } - - public void comment(char[] buffer, int offset, int length) { - if (this.inDTD) { - return; - } - } - - public void startDTD(String name, String publicId, String systemId) { - this.inDTD = true; - } - - public void endDTD() { - this.inDTD = false; - } - - public void startEntity(String name) { - if (this.inDTD) { - return; - } - /* Assumes for now that all are general entities. */ - this.charBuffer.append("&"); - this.charBuffer.append(name); - this.charBuffer.append(";"); - this.inEntity = true; - } - - public void endEntity(String name) { - this.inEntity = false; - } - - public void elementDecl(String name, String model) { - DTDElement dtdElement = new DTDElement(name, model); - this.dtd.addElement(dtdElement); - } - - private void flushCharacters() { - if (this.charBuffer.length() < 1) { - return; - } - if (breakPCDATA) { - /* Note: SAX input has linefeeds normalized to \n. */ - normalizeWhitespace(); - } - this.charBuffer.setLength(0); - } - - private void normalizeWhitespace() { - /* Convert all line-feeds to spaces. */ - convertString(this.charBuffer, "\n", " "); - /* Convert all tabs to spaces. */ - convertString(this.charBuffer, "\t", " "); - /* Remove extra spaces. */ - convertString(this.charBuffer, " ", " "); - } - - } - - public static void main(String[] args) { - if (args == null - || args.length < 2 - || args.length > 3) { - System.out.print("Wrong number of arguments."); - System.exit(1); - } - String input1 = args[0]; - String input2 = args[1]; - String catalog = null; - if (args.length > 2) { - catalog = args[2]; - } - InputStream inputStream = null; try { - FileInputStream fis = null; - fis = new FileInputStream(input1); - inputStream = new BufferedInputStream(fis); - } catch (FileNotFoundException e) { - System.err.println("File not found: " + input1); - System.exit(1); - } - InputSource inputSource1 = new InputSource(inputStream); - - try { - FileInputStream fis = null; - fis = new FileInputStream(input2); - inputStream = new BufferedInputStream(fis); - } catch (FileNotFoundException e) { - System.err.println("File not found: " + input2); - System.exit(1); - } - InputSource inputSource2 = new InputSource(inputStream); - - FOrayXDiff processor = new FOrayXDiff(inputSource1, inputSource2, - catalog); - try { - processor.start(); + FOrayXDiff processor = new FOrayXDiff(urlsToCompare); + processor.compare(); } catch (Exception e) { - System.out.print("Error parsing input."); - e.printStackTrace(); + System.out.println("Error parsing input."); + System.out.println(e.getMessage()); } } Added: trunk/foray/lib/stax-1.2.0_rc2-dev.jar =================================================================== (Binary files differ) Property changes on: trunk/foray/lib/stax-1.2.0_rc2-dev.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/foray/lib/stax-api-1.0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/foray/lib/stax-api-1.0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-15 22:24:32
|
Revision: 7041 Author: victormote Date: 2006-04-15 15:24:24 -0700 (Sat, 15 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7041&view=rev Log Message: ----------- 1. Improve error message for unsupported operations. 2. Add 3 new operations, which seem to be needed by newly-installed fonts. Modified Paths: -------------- trunk/foray/foray-ps/src/java/org/foray/ps/PSDictionary.java trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java trunk/foray/foray-ps/src/java/org/foray/ps/PSSystemDict.java Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSDictionary.java =================================================================== --- trunk/foray/foray-ps/src/java/org/foray/ps/PSDictionary.java 2006-04-15 21:48:07 UTC (rev 7040) +++ trunk/foray/foray-ps/src/java/org/foray/ps/PSDictionary.java 2006-04-15 22:24:24 UTC (rev 7041) @@ -179,4 +179,15 @@ return this.dictionary.size(); } + /** + * See the "maxlength" operator for details. + * @return For level 2 PS implementations, returns the current capacity of + * the dictionary. + */ + public int maxLength() { + /* TODO: There does not seem to be a way to get to the true capacity of + * the Map from here. Punt and return the size for now. */ + return this.dictionary.size(); + } + } Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java =================================================================== --- trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java 2006-04-15 21:48:07 UTC (rev 7040) +++ trunk/foray/foray-ps/src/java/org/foray/ps/PSInterpreter.java 2006-04-15 22:24:24 UTC (rev 7041) @@ -146,6 +146,10 @@ * else. */ private byte lastByteParsed; + /** See the setpacking and currentpacking operators for details of this + * state variable. */ + private boolean packingMode; + /** * Constructor for a PostScript interpreter. * @param logger The logger that should be used. @@ -250,7 +254,7 @@ executionStack.pop(); boolean completed = operator.execute(); if (! completed) { - logger.error("Unsupported operator: " + logger.error("Internal PostScript error: Unsupported operator: " + PSOperator.mapEnumToName(operator.operatorEnum)); } return; @@ -655,6 +659,15 @@ public void setGraphicsState(PSGraphicsState graphicsState) { this.currentGraphicsState = graphicsState; } + + public boolean getPackingMode() { + return this.packingMode; + } + + public void setPackingMode(boolean newPackingMode) { + this.packingMode = newPackingMode; + } + public int getCurrentLine() { return this.currentLine; } Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PSSystemDict.java =================================================================== --- trunk/foray/foray-ps/src/java/org/foray/ps/PSSystemDict.java 2006-04-15 21:48:07 UTC (rev 7040) +++ trunk/foray/foray-ps/src/java/org/foray/ps/PSSystemDict.java 2006-04-15 22:24:24 UTC (rev 7041) @@ -237,7 +237,10 @@ } case PSOperator.OPER_CURRENTOBJECTFORMAT: { return false; } case PSOperator.OPER_CURRENTOVERPRINT: { return false; } - case PSOperator.OPER_CURRENTPACKING: { return false; } + case PSOperator.OPER_CURRENTPACKING: { + currentpacking(); + return true; + } case PSOperator.OPER_CURRENTPAGEDEVICE: { return false; } case PSOperator.OPER_CURRENTPOINT: { return false; } case PSOperator.OPER_CURRENTRGBCOLOR: { return false; } @@ -450,7 +453,10 @@ matrix(); return true; } - case PSOperator.OPER_MAXLENGTH: { return false; } + case PSOperator.OPER_MAXLENGTH: { + maxlength(); + return true; + } case PSOperator.OPER_MOD: { return false; } case PSOperator.OPER_MONITOR: { return false; } case PSOperator.OPER_MOVETO: { return false; } @@ -612,7 +618,10 @@ } case PSOperator.OPER_SETOBJECTFORMAT: { return false; } case PSOperator.OPER_SETOVERPRINT: { return false; } - case PSOperator.OPER_SETPACKING: { return false; } + case PSOperator.OPER_SETPACKING: { + setpacking(); + return true; + } case PSOperator.OPER_SETPAGEDEVICE: { return false; } case PSOperator.OPER_SETPATTERN: { return false; } case PSOperator.OPER_SETRGBCOLOR: { @@ -2129,4 +2138,22 @@ this.currentGS().setFont(font); } + protected void maxlength() throws PSException { + PSDictionary dictionary = popPSDictionary(PSOperator.OPER_MAXLENGTH); + int capacity = dictionary.maxLength(); + PSInteger integer = new PSInteger(this.interpreter, capacity); + pushOperand(integer); + } + + protected void setpacking() throws PSException { + PSBoolean packingMode = popPSBoolean(PSOperator.OPER_SETPACKING); + this.interpreter.setPackingMode(packingMode.value); + } + + protected void currentpacking() throws PSException { + PSBoolean packingMode = new PSBoolean(this.interpreter, + this.interpreter.getPackingMode()); + pushOperand(packingMode); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-04-15 21:48:13
|
Revision: 7040 Author: victormote Date: 2006-04-15 14:48:07 -0700 (Sat, 15 Apr 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7040&view=rev Log Message: ----------- More cleanup of AntTask startup. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-04-15 21:16:52 UTC (rev 7039) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-04-15 21:48:07 UTC (rev 7040) @@ -63,7 +63,8 @@ */ int skippedcount = 0; - SessionConfig configuration; + SessionConfig sessionConfig; + OutputConfig outputConfig; /** * Basic constructor. @@ -87,9 +88,11 @@ } public void run() throws FOrayException { - this.configuration = new SessionConfig(getLogger()); + this.sessionConfig = new SessionConfig(getLogger()); + this.outputConfig = new OutputConfig(getLogger()); if (task.userConfig != null) { - new Options (this.getLogger(), configuration, null, task.userConfig); + new Options (this.getLogger(), sessionConfig, outputConfig, + task.userConfig); } setBaseDirectory(); @@ -178,17 +181,17 @@ } try { if (task.getBasedir() != null) { - configuration.parseOption("base-directory", + sessionConfig.parseOption("base-directory", task.getBasedir().toURL().toExternalForm(), SessionConfig.PRECEDENCE_DEFAULT); } else { - configuration.parseOption("base-directory", + sessionConfig.parseOption("base-directory", fs.getDir(task.getProject()).toURL(). toExternalForm(), SessionConfig.PRECEDENCE_DEFAULT); } task.log("Using base directory: " + - configuration.optionBaseDirectory(), + sessionConfig.optionBaseDirectory(), Project.MSG_DEBUG); } catch (Exception e) { task.log("Error setting base directory: " + e, Project.MSG_ERR); @@ -230,9 +233,9 @@ task.log("FOrayAntTask base directory is invalid:\n" + e, Project.MSG_ERR); } - configuration.setBaseDirectory(url, SessionConfig.PRECEDENCE_DEFAULT); + sessionConfig.setBaseDirectory(url, SessionConfig.PRECEDENCE_DEFAULT); task.log("FOrayAntTask using base directory: " + - configuration.optionBaseDirectory(), + sessionConfig.optionBaseDirectory(), Project.MSG_DEBUG); } @@ -256,19 +259,17 @@ try { FOraySession session = new FOraySession(this.getLogger(), - configuration, null, null, null, null); + sessionConfig, null, null, null, null); FOrayDocument document = new FOrayDocument(session, inputHandler.getInputSource(), parser); - OutputConfig rendererOptions = null; if (this.task.getRendererType() == FOrayTarget.RENDER_XML) { - rendererOptions = new OutputConfig(getLogger()); - rendererOptions.parseOption("fineDetail", "true", + this.outputConfig.parseOption("fineDetail", "true", SessionConfig.PRECEDENCE_DEFAULT); } - OutputTarget renderer = document.makeOutputTarget( - this.task.getRendererType(), rendererOptions); - new FOrayTarget(document, renderer, null, out); + OutputTarget outputTarget = document.makeOutputTarget( + this.task.getRendererType(), this.outputConfig); + new FOrayTarget(document, outputTarget, null, out); session.process(); out.close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |