Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
O
odfhistory
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
odfplugfest
odfhistory
Commits
e18f9aa0
Commit
e18f9aa0
authored
Aug 23, 2015
by
Jos van den Oever
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up whitespace in RNG files.
parent
ee735cea
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
21 deletions
+48
-21
src/odf/OdfHistory.java
src/odf/OdfHistory.java
+0
-1
src/odf/OdfInfo.java
src/odf/OdfInfo.java
+27
-10
src/odf/OdfNormalizer.java
src/odf/OdfNormalizer.java
+4
-2
src/odf/OdfRngInfo.java
src/odf/OdfRngInfo.java
+5
-1
src/odf/OdfZipNormalizer.java
src/odf/OdfZipNormalizer.java
+7
-4
src/odf/Tester.java
src/odf/Tester.java
+5
-2
src/odf/WhitespaceHandler.java
src/odf/WhitespaceHandler.java
+0
-1
No files found.
src/odf/OdfHistory.java
View file @
e18f9aa0
...
...
@@ -2,7 +2,6 @@ package odf;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.nio.file.CopyOption
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.StandardCopyOption
;
...
...
src/odf/OdfInfo.java
View file @
e18f9aa0
...
...
@@ -27,8 +27,9 @@ public class OdfInfo {
private
static
@Nullable
OdfRngInfo
odfRngInfo
;
private
static
@Nullable
OdfRngInfo
manifestRngInfo
;
private
static
@Nullable
OdfRngInfo
rngRngInfo
;
final
boolean
manifest
;
final
FileType
fileType
;
private
@Nullable
ValidationDriver
driver12
;
private
@Nullable
ValidationDriver
driver11
;
final
ErrorHandler
errorHandler
;
...
...
@@ -52,29 +53,38 @@ public class OdfInfo {
return
driver
;
}
OdfInfo
(
boolean
manifest
)
{
this
.
manifest
=
manifest
;
OdfInfo
(
FileType
fileType
)
{
this
.
fileType
=
fileType
;
errorHandler
=
new
ErrorHandler
();
version
=
"1.2"
;
}
enum
FileType
{
RNG
,
ODF
,
ODFMANIFEST
}
public
OdfRngInfo
getRngInfo
(
XML
xml
)
throws
FileNotFoundException
,
SAXException
,
IOException
,
TransformerException
{
synchronized
(
OdfInfo
.
class
)
{
if
(
manifest
)
{
if
(
fileType
==
FileType
.
ODFMANIFEST
)
{
if
(
manifestRngInfo
!=
null
)
{
return
manifestRngInfo
;
}
manifestRngInfo
=
loadInfo
(
"src/rng/OpenDocument-v1.2-os-manifest-schema.rng"
,
xml
);
return
manifestRngInfo
;
}
else
{
}
else
if
(
fileType
==
FileType
.
ODF
)
{
if
(
odfRngInfo
!=
null
)
{
return
odfRngInfo
;
}
odfRngInfo
=
loadInfo
(
"src/rng/OpenDocument-v1.2-os-schema.rng"
,
xml
);
return
odfRngInfo
;
}
else
if
(
fileType
==
FileType
.
RNG
)
{
rngRngInfo
=
loadInfo
(
"src/rng/relaxng.rng"
,
xml
);
return
rngRngInfo
;
}
else
{
throw
new
RuntimeException
();
}
}
}
...
...
@@ -90,28 +100,35 @@ public class OdfInfo {
public
ValidationDriver
getDriver11
()
{
if
(
driver11
!=
null
)
{
return
driver11
;
}
else
if
(
manifest
)
{
}
else
if
(
fileType
==
FileType
.
ODFMANIFEST
)
{
driver11
=
load
(
"src/rng/OpenDocument-manifest-schema-v1.1.rng"
,
errorHandler
);
return
driver11
;
}
else
{
driver11
=
load
(
"src/rng/OpenDocument-schema-v1.1-errata01-complete.rng"
,
}
else
if
(
fileType
==
FileType
.
ODF
)
{
driver11
=
load
(
"src/rng/OpenDocument-schema-v1.1-errata01-complete.rng"
,
errorHandler
);
return
driver11
;
}
else
{
driver11
=
load
(
"src/rng/relaxng.rng"
,
errorHandler
);
return
driver11
;
}
}
public
ValidationDriver
getDriver12
()
{
if
(
driver12
!=
null
)
{
return
driver12
;
}
else
if
(
manifest
)
{
}
else
if
(
fileType
==
FileType
.
ODFMANIFEST
)
{
driver12
=
load
(
"src/rng/OpenDocument-v1.2-os-manifest-schema.rng"
,
errorHandler
);
return
driver12
;
}
else
{
}
else
if
(
fileType
==
FileType
.
ODF
)
{
driver12
=
load
(
"src/rng/OpenDocument-v1.2-os-schema.rng"
,
errorHandler
);
return
driver12
;
}
else
{
driver12
=
load
(
"src/rng/relaxng.rng"
,
errorHandler
);
return
driver12
;
}
}
}
...
...
src/odf/OdfNormalizer.java
View file @
e18f9aa0
...
...
@@ -29,10 +29,12 @@ public class OdfNormalizer {
final
XML
xml
=
new
XML
();
final
OdfInfo
odfManifestInfo
;
final
OdfInfo
odfInfo
;
final
OdfInfo
rngInfo
;
OdfNormalizer
()
{
odfManifestInfo
=
new
OdfInfo
(
true
);
odfInfo
=
new
OdfInfo
(
false
);
odfManifestInfo
=
new
OdfInfo
(
OdfInfo
.
FileType
.
ODFMANIFEST
);
odfInfo
=
new
OdfInfo
(
OdfInfo
.
FileType
.
ODF
);
rngInfo
=
new
OdfInfo
(
OdfInfo
.
FileType
.
RNG
);
}
static
public
LinkedList
<
String
>
cleanManifest
(
Document
manifest
)
{
...
...
src/odf/OdfRngInfo.java
View file @
e18f9aa0
...
...
@@ -197,10 +197,11 @@ class OdfRngInfoParser {
* @return
*/
static
private
QName
parseQName
(
HashMap
<
String
,
String
>
nsmap
,
String
qname
)
{
String
uri
=
null
,
localName
;
String
uri
,
localName
;
int
p
=
qname
.
indexOf
(
":"
);
if
(
p
==
-
1
)
{
localName
=
qname
;
uri
=
nsmap
.
get
(
""
);
}
else
{
String
prefix
=
qname
.
substring
(
0
,
p
);
localName
=
qname
.
substring
(
p
+
1
);
...
...
@@ -330,6 +331,9 @@ class OdfRngInfoParser {
final
Attr
a
=
(
Attr
)
atts
.
item
(
i
);
if
(
xmlns
.
equals
(
a
.
getNamespaceURI
()))
{
ns
.
put
(
a
.
getLocalName
(),
a
.
getValue
());
}
else
if
(
a
.
getNamespaceURI
()
==
null
&&
a
.
getLocalName
().
equals
(
"ns"
))
{
ns
.
put
(
""
,
a
.
getValue
());
}
}
return
ns
;
...
...
src/odf/OdfZipNormalizer.java
View file @
e18f9aa0
...
...
@@ -38,12 +38,15 @@ public class OdfZipNormalizer {
throws
TransformerException
,
XMLStreamException
,
IOException
,
SAXException
,
NormalizeException
{
FileInputStream
in
=
new
FileInputStream
(
input
);
Document
doc
=
odfNormalizer
.
xml
.
parse
(
in
,
odfNormalizer
.
odfInfo
);
OdfInfo
info
=
odfNormalizer
.
odfInfo
;
if
(
input
.
getAbsolutePath
().
endsWith
(
".rng"
))
{
info
=
odfNormalizer
.
rngInfo
;
}
Document
doc
=
odfNormalizer
.
xml
.
parse
(
in
,
info
);
in
.
close
();
normalizeOdf
(
doc
,
odfNormalizer
);
OdfHistory
.
pretty
(
doc
,
output
,
odfNormalizer
.
odfInfo
.
getRngInfo
(
odfNormalizer
.
xml
)
.
getElementsWithNoText
());
OdfHistory
.
pretty
(
doc
,
output
,
info
.
getRngInfo
(
odfNormalizer
.
xml
)
.
getElementsWithNoText
());
}
public
void
normalize
(
Path
input
,
Path
output
)
throws
ZipException
,
...
...
src/odf/Tester.java
View file @
e18f9aa0
...
...
@@ -11,6 +11,8 @@ import java.util.Arrays;
import
javax.xml.stream.XMLStreamException
;
import
javax.xml.transform.TransformerException
;
import
odf.OdfInfo.FileType
;
import
org.w3c.dom.Document
;
import
org.xml.sax.SAXException
;
...
...
@@ -41,8 +43,9 @@ public class Tester {
static
private
boolean
runTest
(
Path
beforePath
,
OdfNormalizer
odfNormalizer
)
throws
TestFailException
,
XMLStreamException
,
SAXException
{
Document
doc
;
OdfInfo
odfInfo
=
new
OdfInfo
(
beforePath
.
toString
().
contains
(
"/manifest/"
));
FileType
type
=
beforePath
.
toString
().
contains
(
"/manifest/"
)
?
OdfInfo
.
FileType
.
ODFMANIFEST
:
OdfInfo
.
FileType
.
ODF
;
OdfInfo
odfInfo
=
new
OdfInfo
(
type
);
try
{
doc
=
odfNormalizer
.
xml
.
parse
(
new
FileInputStream
(
beforePath
.
toFile
()),
odfInfo
);
...
...
src/odf/WhitespaceHandler.java
View file @
e18f9aa0
...
...
@@ -53,5 +53,4 @@ class WhitespaceHandler extends XMLFilterImpl {
public
void
ignorableWhitespace
(
@Nullable
char
[]
ch
,
int
start
,
int
length
)
throws
SAXException
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment