Skip to content

Commit 5d58eda

Browse files
committed
more review comments
1 parent 6360a31 commit 5d58eda

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

xmlua/document.lua

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ local Document = {}
33
local libxml2 = require("xmlua.libxml2")
44
local ffi = require("ffi")
55
local converter = require("xmlua.converter")
6-
local to_string = converter.to_string
76

87
local Serializable = require("xmlua.serializable")
98
local Searchable = require("xmlua.searchable")
@@ -179,7 +178,7 @@ end
179178

180179
do -- C14N methods
181180
-- list can be a string (space separated), an array of strings, or nil
182-
local function get_namespace_prefix_array(list)
181+
local function create_xml_string_array(list)
183182
local list = list or {}
184183

185184
if type(list) == "string" then
@@ -312,8 +311,8 @@ do -- C14N methods
312311

313312

314313

315-
--- Canonicalise an xmlDocument or set of elements.
316-
-- @param self xmlDoc from which to canonicalize elements
314+
--- Canonicalise an XML document or set of elements.
315+
-- @param self xmlua.Document from which to canonicalize elements
317316
-- @tparam[opt={}] array|function select array of nodes to include, or function to determine if a node should be
318317
-- included in the canonicalized output. Signature: `boolean = function(node, parent)`. Defaults to an empty
319318
-- array, which canonicalizes the entire document.
@@ -332,7 +331,7 @@ do -- C14N methods
332331
end
333332
mode = C14N_MODES_LOOKUP[mode]
334333

335-
local prefixes = get_namespace_prefix_array(opts.inclusive_ns_prefixes)
334+
local prefixes = create_xml_string_array(opts.inclusive_ns_prefixes)
336335
local buffer = libxml2.xmlBufferCreate()
337336
local output_buffer = libxml2.xmlOutputBufferCreate(buffer)
338337

@@ -342,20 +341,20 @@ do -- C14N methods
342341
end
343342
if type(select) == "function" then -- callback function
344343
-- wrap the callback to pass wrapped objects, and return 1 or 0
345-
local cbwrapper = function(_, nodePtr, parentPtr)
344+
local callback = function(_, nodePtr, parentPtr)
346345
if select(wrap_raw_node(self, nodePtr), wrap_raw_node(self, parentPtr)) then
347346
return 1
348347
else
349348
return 0
350349
end
351350
end
352-
success = libxml2.xmlC14NExecute(self.document, cbwrapper, nil, mode,
353-
prefixes, with_comments, output_buffer)
351+
success = libxml2.xmlC14NExecute(self.document, callback, nil, mode,
352+
prefixes, with_comments, output_buffer)
354353

355354
elseif type(select) == "table" then -- array of nodes
356-
local nodeSet = create_xml_node_set(select)
357-
success = libxml2.xmlC14NDocSaveTo(self.document, nodeSet, mode,
358-
prefixes, with_comments, output_buffer)
355+
local node_set = create_xml_node_set(select)
356+
success = libxml2.xmlC14NDocSaveTo(self.document, node_set, mode,
357+
prefixes, with_comments, output_buffer)
359358
else
360359
error("select must be a function or an array of nodes")
361360
end

0 commit comments

Comments
 (0)