Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ronove
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kaj Koivunen
Ronove
Commits
35554b3f
Commit
35554b3f
authored
2 years ago
by
Kaj Koivunen
Browse files
Options
Downloads
Patches
Plain Diff
XML: value -> content
parent
d9947f89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/kotlin/DictionaryParser.kt
+3
-3
3 additions, 3 deletions
src/main/kotlin/DictionaryParser.kt
src/main/kotlin/XMLParser.kt
+15
-1
15 additions, 1 deletion
src/main/kotlin/XMLParser.kt
with
18 additions
and
4 deletions
src/main/kotlin/DictionaryParser.kt
+
3
−
3
View file @
35554b3f
...
...
@@ -78,7 +78,7 @@ class DictionaryParser {
}
}
element
(
"literal"
)
{
start
{
character
!!
.
literal
=
value
()
!!
}
start
{
character
!!
.
literal
=
content
()
!!
}
}
element
(
"reading_meaning"
)
{
start
{
rmgroup
=
RMGroup
()
}
...
...
@@ -91,7 +91,7 @@ class DictionaryParser {
start
{
rmgroup
!!
.
meaning
.
add
(
Pair
(
attribute
(
"m_lang"
),
value
()
!!
content
()
!!
))
}
}
...
...
@@ -99,7 +99,7 @@ class DictionaryParser {
start
{
rmgroup
!!
.
reading
.
add
(
Pair
(
attribute
(
"r_type"
),
value
()
!!
content
()
!!
))
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/kotlin/XMLParser.kt
+
15
−
1
View file @
35554b3f
...
...
@@ -44,11 +44,19 @@ class XMLParser private constructor(path: String) {
@DSL
inner
class
Element
(
private
val
name
:
String
,
private
val
reader
:
XMLEventReader
,
private
val
event
:
XMLEvent
)
{
/**
* Specify code to execute when encountering a starting tag of the specified element
* @param f code to execute
*/
fun
start
(
f
:
StartElement
.()
->
Unit
)
{
if
(
event
.
isStartElement
&&
event
.
asStartElement
().
name
.
localPart
.
toString
()
==
name
)
StartElement
(
reader
,
event
.
asStartElement
()).
f
()
}
/**
* Specify code to execute when encountering a closing tag of the specified element
* @param f code to execute
*/
fun
end
(
f
:
()
->
Unit
)
{
if
(
event
.
isEndElement
&&
event
.
asEndElement
().
name
.
localPart
.
toString
()
==
name
)
f
()
...
...
@@ -56,7 +64,10 @@ class XMLParser private constructor(path: String) {
@DSL
inner
class
StartElement
(
private
val
reader
:
XMLEventReader
,
private
val
event
:
javax
.
xml
.
stream
.
events
.
StartElement
)
{
fun
value
():
String
?
{
/**
* Get the content of the current element
*/
fun
content
():
String
?
{
return
try
{
reader
.
peek
().
asCharacters
().
data
}
catch
(
e
:
ClassCastException
)
{
...
...
@@ -64,6 +75,9 @@ class XMLParser private constructor(path: String) {
}
}
/**
*
*/
fun
attribute
(
attr
:
String
):
String
?
=
event
.
getAttributeByName
(
QName
(
attr
))
?.
value
}
}
...
...
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