Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
any2txt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nlpworkers
any2txt
Commits
206587df
Commit
206587df
authored
May 30, 2023
by
Paweł Walkowiak
Browse files
Options
Downloads
Patches
Plain Diff
Mv code
parent
79f066cf
Branches
Branches containing commit
No related tags found
1 merge request
!1
Support xml
Pipeline
#10755
failed
May 30, 2023
Stage: build_develop_xml
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
module/src/main/java/pl/clarin/any2txt/Converter.java
+11
-8
11 additions, 8 deletions
module/src/main/java/pl/clarin/any2txt/Converter.java
with
11 additions
and
8 deletions
module/src/main/java/pl/clarin/any2txt/Converter.java
+
11
−
8
View file @
206587df
...
...
@@ -76,19 +76,22 @@ public class Converter extends Worker {
File
file
=
new
File
(
fileIn
);
TikaInputStream
inS
;
try
{
DocumentBuilder
builder
=
DocumentBuilderFactory
.
newInstance
().
newDocumentBuilder
();
Document
doc
=
builder
.
parse
(
file
);
}
catch
(
IOException
|
SAXException
|
ParserConfigurationException
e
)
{
Logger
.
getLogger
(
Converter
.
class
.
getName
()).
log
(
Level
.
WARNING
,
"Problems with XML parsing "
+
e
.
getMessage
()
,
e
.
getMessage
());
}
//
try {
//
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
//
Document doc = builder.parse(file);
//
}
//
catch (IOException | SAXException | ParserConfigurationException e) {
//
Logger.getLogger(Converter.class.getName()).log(Level.WARNING, "Problems with XML parsing " + e.getMessage() , e.getMessage());
//
}
try
{
Metadata
metadata
=
new
Metadata
();
metadata
.
set
(
"Content-Encoding"
,
"CP1250"
);
inS
=
TikaInputStream
.
get
(
file
,
metadata
);
DocumentBuilder
builder
=
DocumentBuilderFactory
.
newInstance
().
newDocumentBuilder
();
Document
doc
=
builder
.
parse
(
file
);
Tika
tika
=
new
Tika
();
Logger
.
getLogger
(
Converter
.
class
.
getName
()).
log
(
Level
.
INFO
,
"Detected file type: "
+
tika
.
detect
(
inS
));
// || "text/plain".equals(tika.detect(inS))
...
...
@@ -119,7 +122,7 @@ public class Converter extends Worker {
}
catch
(
FileNotFoundException
ex
)
{
Logger
.
getLogger
(
Converter
.
class
.
getName
()).
log
(
Level
.
WARNING
,
"File not found"
,
ex
.
getMessage
());
saveEmptyFile
(
fileOut
);
}
catch
(
IOException
|
TikaException
ex
)
{
}
catch
(
IOException
|
TikaException
|
SAXException
|
ParserConfigurationException
ex
)
{
Logger
.
getLogger
(
Converter
.
class
.
getName
()).
log
(
Level
.
WARNING
,
"Problems in Tika processing "
+
ex
.
getMessage
()
,
ex
.
getMessage
());
if
(
ex
.
getMessage
().
contains
(
"XML parse error"
))
{
// try {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment