Map the weird numeric escapes to textual ones
This commit is contained in:
@@ -17,12 +17,7 @@ func normalizeXMLWhitespace(s string) string {
|
||||
s = re.ReplaceAllString(strings.TrimSpace(s), " ")
|
||||
|
||||
// Normalize XML entities for comparison
|
||||
s = strings.ReplaceAll(s, "'", "'")
|
||||
s = strings.ReplaceAll(s, """, """)
|
||||
s = strings.ReplaceAll(s, """, "\"")
|
||||
s = strings.ReplaceAll(s, "<", "<")
|
||||
s = strings.ReplaceAll(s, ">", ">")
|
||||
s = strings.ReplaceAll(s, "&", "&")
|
||||
s = ConvertToNamedEntities(s)
|
||||
|
||||
return s
|
||||
}
|
||||
@@ -52,7 +47,7 @@ func TestXMLProcessor_Process_NodeValues(t *testing.T) {
|
||||
<catalog>
|
||||
<book id="bk101">
|
||||
<author>Gambardella, Matthew</author>
|
||||
<title>XML Developer's Guide</title>
|
||||
<title>XML Developer's Guide</title>
|
||||
<genre>Computer</genre>
|
||||
<price>89.9</price>
|
||||
<publish_date>2000-10-01</publish_date>
|
||||
@@ -1015,9 +1010,9 @@ func TestXMLProcessor_Process_ElementReordering(t *testing.T) {
|
||||
luaExpr := `
|
||||
-- With table approach, we can reorder elements by redefining the table
|
||||
-- Store the values
|
||||
local artist = v.artist
|
||||
local title = v.title
|
||||
local year = v.year
|
||||
local artist = v.attr.artist
|
||||
local title = v.attr.title
|
||||
local year = v.attr.year
|
||||
|
||||
-- Clear the table
|
||||
for k in pairs(v) do
|
||||
@@ -1025,9 +1020,9 @@ func TestXMLProcessor_Process_ElementReordering(t *testing.T) {
|
||||
end
|
||||
|
||||
-- Add elements in the desired order
|
||||
v.title = title
|
||||
v.artist = artist
|
||||
v.year = year
|
||||
v.attr.title = title
|
||||
v.attr.artist = artist
|
||||
v.attr.year = year
|
||||
`
|
||||
|
||||
result, modCount, matchCount, err := p.ProcessContent(content, "//song", luaExpr)
|
||||
@@ -1178,13 +1173,13 @@ func TestXMLProcessor_Process_DynamicXPath(t *testing.T) {
|
||||
expected := `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<settings>
|
||||
<setting name="timeout" value="60" />
|
||||
<setting name="retries" value="3" />
|
||||
<setting name="backoff" value="exponential" />
|
||||
<setting name="timeout" value="60"></setting>
|
||||
<setting name="retries" value="3"></setting>
|
||||
<setting name="backoff" value="exponential"></setting>
|
||||
</settings>
|
||||
<advanced>
|
||||
<setting name="logging" value="debug" />
|
||||
<setting name="timeout" value="120" />
|
||||
<setting name="logging" value="debug"></setting>
|
||||
<setting name="timeout" value="120"></setting>
|
||||
</advanced>
|
||||
</configuration>`
|
||||
|
||||
@@ -1192,7 +1187,7 @@ func TestXMLProcessor_Process_DynamicXPath(t *testing.T) {
|
||||
p := &XMLProcessor{}
|
||||
|
||||
// Double all timeout values in the configuration
|
||||
result, modCount, matchCount, err := p.ProcessContent(content, "//setting[@name='timeout']/@value", "v = v * 2")
|
||||
result, modCount, matchCount, err := p.ProcessContent(content, "//setting[@name='timeout']/@value", "v.value = v.value * 2")
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Error processing content: %v", err)
|
||||
|
Reference in New Issue
Block a user