-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from LikeTheSalad/release/2.3.0
Release/2.3.0
- Loading branch information
Showing
11 changed files
with
90 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
Change Log | ||
========== | ||
|
||
Version 2.3.0 | ||
--- | ||
|
||
* Keeping xml tags from xml string body. | ||
|
||
Version 2.2.2 | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
...src/main/java/com/likethesalad/tools/resource/collector/android/data/xml/XmlFileFinder.kt
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...ctor/src/main/java/com/likethesalad/tools/resource/collector/android/data/xml/XmlUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.likethesalad.tools.resource.collector.android.data.xml | ||
|
||
import com.likethesalad.tools.resource.collector.android.data.valuedir.ValueDir | ||
import org.w3c.dom.Node | ||
import java.io.File | ||
import java.io.StringWriter | ||
import javax.xml.transform.OutputKeys | ||
import javax.xml.transform.TransformerException | ||
import javax.xml.transform.TransformerFactory | ||
import javax.xml.transform.dom.DOMSource | ||
import javax.xml.transform.stream.StreamResult | ||
|
||
object XmlUtils { | ||
|
||
private val XML_FORMAT = Regex(".+\\.[xX][mM][lL]\$") | ||
private val OUTER_XML_TAGS_PATTERN = Regex("^<[^>]*>|<[^>]*>\$") | ||
private val contentExtractor by lazy { | ||
val transformer = TransformerFactory.newInstance().newTransformer() | ||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes") | ||
transformer | ||
} | ||
|
||
fun findXmlFiles(valueDir: ValueDir): List<File> { | ||
return valueDir.dir.listFiles { _, name -> | ||
isXmlFile(name) | ||
}?.toList() ?: emptyList() | ||
} | ||
|
||
private fun isXmlFile(name: String): Boolean { | ||
return XML_FORMAT.matches(name) | ||
} | ||
|
||
fun getContents(node: Node): String { | ||
val outText = StringWriter() | ||
val streamResult = StreamResult(outText) | ||
return try { | ||
contentExtractor.transform(DOMSource(node), streamResult) | ||
val text = outText.toString() | ||
return OUTER_XML_TAGS_PATTERN.replace(text, "") | ||
} catch (e: TransformerException) { | ||
node.textContent | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
kotlin.code.style=official | ||
kotlin.version=1.9.22 | ||
group=com.likethesalad.tools.resources | ||
version=2.2.2 | ||
version=2.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters