From be72260fdad8c3f21360ead4922c8263c3ea0c61 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:39:38 -0500 Subject: [PATCH 01/13] addnode update - return the added element --- src/xmlutils/{creators.jl => addnode.jl} | 107 ++++++++++++++++------- 1 file changed, 75 insertions(+), 32 deletions(-) rename src/xmlutils/{creators.jl => addnode.jl} (64%) diff --git a/src/xmlutils/creators.jl b/src/xmlutils/addnode.jl similarity index 64% rename from src/xmlutils/creators.jl rename to src/xmlutils/addnode.jl index fc4d938..a5b8170 100644 --- a/src/xmlutils/creators.jl +++ b/src/xmlutils/addnode.jl @@ -1,6 +1,6 @@ export addelm! ################################################################ -# Creators +# Add node ################################################################ # Document ################################################################ @@ -14,9 +14,11 @@ function addelm!(aml::Document, name::String, value::T, argAmlType::Type{<:AbsDo if hasroot(aml) amlNode = root(aml) - addelm!(amlNode, name, value, argAmlType) + elm = addelm!(amlNode, name, value, argAmlType) + return elm elseif hasfield(T, :aml) - setroot!(aml, value.aml) + elm = setroot!(aml, value.aml) + return elm else error("You cannot insert $(T) in the document directly. Define a @aml defined field for xml or html document struct") end @@ -39,8 +41,8 @@ function addelm!(aml::Document, name::String, value::Vector, argAmlType::Type{<: if hasroot(aml) amlNode = root(aml) - addelm!(amlNode, name, value, argAmlType) - + elm = addelm!(amlNode, name, value, argAmlType) + return elm else error("You cannot insert a vector in the document directly. Define a @aml defined field for xml or html document struct") end @@ -53,13 +55,15 @@ end # String @transform function addelm!(aml::Node, name::String,value::AbstractString, argAmlType::Type{allsubtypes(AbsNormal)}) if !isnothing(value) # do nothing if value is nothing - addelement!(aml, name, value) + elm = addelement!(aml, name, value) + return elm end end function addelm!(aml::Node, name::String,value::AbstractString, argAmlType::Type{AbsAttribute}) if !isnothing(value) # do nothing if value is nothing - link!(aml, AttributeNode(name, value)) + elm = link!(aml, AttributeNode(name, value)) + return elm end end @@ -68,12 +72,14 @@ function addelm!(aml::Node, indexstr::String,value::AbstractString, argAmlType:: if index < length(elements(aml)) desired_node = elements(aml)[index] if !isnothing(value) # do nothing if value is nothing - linkprev!(desired_node, TextNode(value)) + elm = linkprev!(desired_node, TextNode(value)) + return elm end else desired_node = elements(aml)[end] if !isnothing(value) # do nothing if value is nothing - linknext!(desired_node, TextNode(value)) + elm = linknext!(desired_node, TextNode(value)) + return elm end end end @@ -81,13 +87,15 @@ end # Number (and also Bool <:Number) @transform function addelm!(aml::Node, name::String, value::Number, argAmlType::Type{allsubtypes(AbsNormal)}) if !isnothing(value) # do nothing if value is nothing - addelement!(aml, name, string(value)) + elm = addelement!(aml, name, string(value)) + return elm end end function addelm!(aml::Node, name::String, value::Number, argAmlType::Type{AbsAttribute}) if !isnothing(value) # do nothing if value is nothing - link!(aml, AttributeNode(name, string(value))) + elm = link!(aml, AttributeNode(name, string(value))) + return elm end end @@ -96,12 +104,14 @@ function addelm!(aml::Node, indexstr::String, value::Number, argAmlType::Type{Ab if index < length(elements(aml)) desired_node = elements(aml)[index] if !isnothing(value) # do nothing if value is nothing - linkprev!(desired_node, TextNode(string(value))) + elm = linkprev!(desired_node, TextNode(string(value))) + return elm end else desired_node = elements(aml)[end] if !isnothing(value) # do nothing if value is nothing - linknext!(desired_node, TextNode(string(value))) + elm = linknext!(desired_node, TextNode(string(value))) + return elm end end end @@ -109,31 +119,41 @@ end # Other function addelm!(aml::Node, name::String, value::T, argAmlType::Type{<:AbsNormal}) where {T} if hasfield(T, :aml) - link!(aml,value.aml) + elm = link!(aml,value.aml) + return elm elseif Tables.istable(value) - link!(aml,amlTable(value)) + elm = link!(aml, amlTable(value)) + return elm elseif hasmethod(aml, Tuple{T}) - link!(aml,aml(value)) + elm = link!(aml,aml(value)) + return elm else - addelement!(aml, name, string(value)) + elm = addelement!(aml, name, string(value)) + return elm + end end function addelm!(aml::Node, name::String, value::T, argAmlType::Type{AbsAttribute}) where {T} if hasfield(T, :aml) - link!(aml, AttributeNode(name, value.aml)) + elm = link!(aml, AttributeNode(name, value.aml)) + return elm elseif Tables.istable(value) - link!(aml, AttributeNode(name, amlTable(value))) + elm = link!(aml, AttributeNode(name, amlTable(value))) + return elm elseif hasmethod(aml, Tuple{T}) - link!(aml, AttributeNode(name, aml(value))) + elm = link!(aml, AttributeNode(name, aml(value))) + return elm else - link!(aml, AttributeNode(name, string(value))) + elm = link!(aml, AttributeNode(name, string(value))) + return elm + end end @@ -143,31 +163,41 @@ function addelm!(aml::Node, indexstr::String, value::T, argAmlType::Type{AbsText desired_node = elements(aml)[index] if hasfield(T, :aml) - linkprev!(desired_node, TextNode(value.aml)) + elm = linkprev!(desired_node, TextNode(value.aml)) + return elm elseif Tables.istable(value) - linkprev!(desired_node, TextNode(amlTable(value))) + elm = linkprev!(desired_node, TextNode(amlTable(value))) + return elm elseif hasmethod(aml, Tuple{T}) - linkprev!(desired_node, TextNode(aml(value))) + elm = linkprev!(desired_node, TextNode(aml(value))) + return elm else - linkprev!(desired_node, TextNode(string(value))) + elm = linkprev!(desired_node, TextNode(string(value))) + return elm + end else desired_node = elements(aml)[end] if hasfield(T, :aml) - linknext!(desired_node, TextNode(value.aml)) + elm = linknext!(desired_node, TextNode(value.aml)) + return elm elseif Tables.istable(value) - linknext!(desired_node, TextNode(amlTable(value))) + elm = linknext!(desired_node, TextNode(amlTable(value))) + return elm elseif hasmethod(aml, Tuple{T}) - linknext!(desired_node, TextNode(aml(value))) + elm = linknext!(desired_node, TextNode(aml(value))) + return elm else - linknext!(desired_node, TextNode(string(value))) + elm = linknext!(desired_node, TextNode(string(value))) + return elm + end end end @@ -182,7 +212,11 @@ end allsubtypes_butAbsText(t) = setdiff(allsubtypes(AbsDocOrNode), [AbsText]) @transform function addelm!(aml::Node, name::String, values::Vector, argAmlType::Type{allsubtypes_butAbsText(AbsDocOrNode)}) - foreach(x-> addelm!(aml, name, x, argAmlType), values) + elms = Vector{Union{Node, Nothing}}(undef, length(values)) + for (ielm, value) in enumerate(values) + elms[ielm] = addelm!(aml, name, value, argAmlType) + end + return elms end function addelm!(aml::Node, indicesstr::String, values::Vector, argAmlType::Type{AbsText}) @@ -190,7 +224,13 @@ function addelm!(aml::Node, indicesstr::String, values::Vector, argAmlType::Type if indices isa Colon indices = 1:length(elements(aml)) end - foreach((x, i)-> addelm!(aml, string(i), x, argAmlType), zip(values, indices)) + elms = Vector{Union{Node, Nothing}}(undef, length(indices)) + ielm = 1 + for (value, index) in zip(values, indices) + elms[ielm] = addelm!(aml, string(index), value, argAmlType) + ielm += 1 + end + return elms end ################################################################ @@ -200,7 +240,10 @@ end # name is discarded now: actual names are stored in the Dict itself # elements are added directly # for AbsText, v_name is considered as the text index + elms = Vector{Union{Node, Nothing}}(undef, length(values)) + ielm = 1 for (v_name, v_value) in values - addelm!(aml, v_name, v_value, argAmlType) + elms[ielm] = addelm!(aml, v_name, v_value, argAmlType) + ielm += 1 end end From 6ad00b29717ea6418656ae6021c4f9dbacfeb003 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:40:15 -0500 Subject: [PATCH 02/13] Update and move extractor utilities --- .../{extractor_utils.jl => findnode.jl} | 84 ++++++++++++++++--- 1 file changed, 71 insertions(+), 13 deletions(-) rename src/xmlutils/{extractor_utils.jl => findnode.jl} (64%) diff --git a/src/xmlutils/extractor_utils.jl b/src/xmlutils/findnode.jl similarity index 64% rename from src/xmlutils/extractor_utils.jl rename to src/xmlutils/findnode.jl index 82304b7..fe88c71 100644 --- a/src/xmlutils/extractor_utils.jl +++ b/src/xmlutils/findnode.jl @@ -1,16 +1,69 @@ -export findalllocal, findfirstlocal, findtext, findtextloacl, findvecttextlocal ################################################################ -# Searchers Utils +# Utilities +################################################################ +function Base.get(node::Node, name::String, defval) + if haskey(node, name) + return node[name] + else + return defval + end +end +################################################################ + +""" + findfirstatt(name, node) + +Finds the first attribute with `name` + +findfirst with ignoring namespaces. It considers att.name for returning the elements + +Much faster than EzXML.findfirst +""" +function findfirstatt(name::String, node::Node) + out = nothing # return nothing if nothing is found + for att in eachattribute(node) + if att.name == name + out = att + break + end + end + return out +end + +""" + findallatt(string, node) + +Finds all the attributes with `name` + +findallatt with ignoring namespaces. It considers att.name for returning the elements + +Much faster than EzXML.findall +""" +function findallatt(name::String, node::Node) + out = Node[] + for att in eachattribute(node) + if att.name == name + push!(out, att) + end + end + if !isempty(out) + return out + else # return nothing if nothing is found + return nothing + end +end + + ################################################################ # Local searchers (no namespace) """ - findfirstlocal(string, node) + findfirstelm(string, node) findfirst with ignoring namespaces. It considers element.name for returning the elements Much faster than EzXML.findfirst """ -function findfirstlocal(name::String, node::Node) +function findfirstelm(name::String, node::Node) out = nothing # return nothing if nothing is found for child in eachelement(node) if child.name == name @@ -22,13 +75,13 @@ function findfirstlocal(name::String, node::Node) end """ - findalllocal(string, node) + findallelm(string, node) -findalllocal with ignoring namespaces. It considers element.name for returning the elements +findallelm with ignoring namespaces. It considers element.name for returning the elements Much faster than EzXML.findall """ -function findalllocal(name::String, node::Node) +function findallelm(name::String, node::Node) out = Node[] for child in eachelement(node) if child.name == name @@ -42,6 +95,9 @@ function findalllocal(name::String, node::Node) end end +################################################################ +# Text node utils + function findtext(indexstr::String, node::Node) if indexstr == "" index = 1 @@ -83,13 +139,13 @@ function parse_textindex(indexstr::String) end """ - findtextlocal(index::Integer, node) + findfirsttext(index::Integer, node) finds the text node at position given by index. faster than `findtext()` """ -function findtextlocal(index::Integer, node::Node) +function findfirsttext(index::Integer, node::Node) iText = 0 out = nothing # return nothing if nothing is found for child in eachnode(node) @@ -103,7 +159,7 @@ function findtextlocal(index::Integer, node::Node) end return out end -function findtextlocal(index::Float64, node::Node) +function findfirsttext(index::Float64, node::Node) if index != Inf error("index should be \"end\"") end @@ -133,13 +189,13 @@ function parse_textindices(indicesstr::String) end """ - findvecttextlocal(indices, node) + findalltext(indices, node) finds the text node at positions given by indices. faster than `findvecttext()` """ -function findvecttextlocal(indices::Colon, node::Node) +function findalltext(indices::Colon, node::Node) out = Node[] for child in eachnode(node) if istext(child) @@ -153,7 +209,7 @@ function findvecttextlocal(indices::Colon, node::Node) end end -function findvecttextlocal(indices::AbstractVector, node::Node) +function findalltext(indices::AbstractVector, node::Node) out = Node[] iText = 0 for child in eachnode(node) @@ -170,3 +226,5 @@ function findvecttextlocal(indices::AbstractVector, node::Node) return nothing end end + +################################################################ From fc547ea0f7da2b70c1629bef99059f87eacaa4c6 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:40:32 -0500 Subject: [PATCH 03/13] findnode (findfirst and findall) --- src/xmlutils/findnode.jl | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/xmlutils/findnode.jl b/src/xmlutils/findnode.jl index fe88c71..f6e1fa8 100644 --- a/src/xmlutils/findnode.jl +++ b/src/xmlutils/findnode.jl @@ -1,3 +1,63 @@ +export findfirst, findall +################################################################ +# Find Node +################################################################ +# findfirst +function findfirst(name::String, doc::Document, argAmlType::Type{<:AbsNode}) + elm = findfirst(name, root(doc), argAmlType) + return elm +end + +function findfirst(name::String, node::Node, argAmlType::Type{<:AbsNormal}) + # if hasdocument(node) + # elm = findfirst(name, node) + # else + elm = findfirstelm(name, node) + # end + return elm +end + +function findfirst(name::String, node::Node, argAmlType::Type{AbsAttribute}) + elms = findfirstatt(name, node) + return elms +end + +function findfirst(indexstr::String, node::Node, argAmlType::Type{AbsText}) + index = parse_textindex(indexstr) + elm = findfirsttext(index, node) + return elm +end +################################################################ +# findall +function findall(name::String, doc::Document, argAmlType::Type{<:AbsNode}) + elms = findall(name, root(doc), argAmlType) + return elms +end + +function findall(name::String, node::Node, argAmlType::Type{<:AbsNormal}) + # if hasdocument(node) + # elms = findall(name, node) # a vector of Node elements + # else + elms = findallelm(name, node) # a vector of Node elements + # end + return elms +end + +function findall(name::String, node::Node, argAmlType::Type{AbsAttribute}) + elms = findallatt(name, node) + return elms +end + +function findall(indicesstr::String, node::Node, argAmlType::Type{AbsText}) + indices = parse_textindices(indicesstr) + elms = findalltext(indices, node) + return elms +end + + + + + ################################################################ # Utilities ################################################################ From c739d9ac001165888175e36bbc74d41849acb886 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:41:21 -0500 Subject: [PATCH 04/13] nodeparse --- src/xmlutils/nodeparse.jl | 108 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/xmlutils/nodeparse.jl diff --git a/src/xmlutils/nodeparse.jl b/src/xmlutils/nodeparse.jl new file mode 100644 index 0000000..9888d61 --- /dev/null +++ b/src/xmlutils/nodeparse.jl @@ -0,0 +1,108 @@ +# TODO use traits for hasmethod checks + +# Scalar parsers + +# content input +""" + noedparse(type::Type, node) + nodeparse(type::Type, content) + noedparse(::Type{Vector{T}}, nodes) + nodeparse(::Type{Vector{T}}, contents) +Parses a node content with the specidied type +""" +nodeparse(type::Type{<:Number}, content::String) = parse(type, content) +nodeparse(type::Type{<:AbstractString}, content::String) = content +function nodeparse(type::Type, content::String) + # TODO: better specialized method detection + # https://julialang.slack.com/archives/C6A044SQH/p1578442480438100 + if hasmethod(type, Tuple{String}) && Core.Compiler.return_type(type, Tuple{Node})=== Union{} + return type(content) + elseif hasmethod(convert, Tuple{String, type}) + return convert(type, content) + elseif hasmethod(parse, Tuple{type, String}) + return parse(type, content) + else + error("Could not parse a String as type $type") + end +end + +# elm input +nodeparse(type::Type{<:Union{Number, AbstractString}}, elm::Node) = nodeparse(type, elm.content) +function nodeparse(type::Type, elm::Node) + content = elm.content + if hasmethod(type, Tuple{String}) && Core.Compiler.return_type(type, Tuple{Node})=== Union{} + return type(content) + elseif hasmethod(convert, Tuple{String, type}) + return convert(type, content) + elseif hasmethod(parse, Tuple{type, String}) + return parse(type, content) + else + # should be the last to avoid invoking generic methods + return type(elm) + end +end + +# Vector parsers +# both elm and content input + +# TODO slow for other than String|Number but compact +numorstr(::Nothing) = [Number, AbstractString] +@transform function nodeparse(type::Type{<:numorstr()}, elmsOrContents::Vector{Node}) + return nodeparse.(type, elmsOrContents) +end +@transform function nodeparse(type::Type{<:numorstr()}, elmsOrContents::Vector{String}) + return nodeparse.(type, elmsOrContents) +end +# TODO Faster code, but has redundancy: + +function nodeparse(::Type{T}, contents::Vector{String}) where {T} + elms_typed = Vector{T}(undef, length(contents)) + i = 1 + if hasmethod(type, Tuple{String}) && Core.Compiler.return_type(type, Tuple{Node})=== Union{} + for content in contents + elms_typed[i] = type(content) + i+=1 + end + elseif hasmethod(convert, Tuple{String, type}) + for content in contents + elms_typed[i] = convert(type, content) + i+=1 + end + elseif hasmethod(parse, Tuple{type, String}) + for content in contents + elms_typed[i] = parse(type, content) + i+=1 + end + else + error("Could not parse a String as type $type") + end + return elms_typed +end + +function nodeparse(type::Type{T}, elms::Vector{Node}) where {T} + elms_typed = Vector{T}(undef, length(elms)) + i = 1 + if hasmethod(type, Tuple{String}) && Core.Compiler.return_type(type, Tuple{Node})=== Union{} + for elm in elms + elms_typed[i] = type(elm.content) + i+=1 + end + elseif hasmethod(convert, Tuple{String, type}) + for elm in elms + elms_typed[i] = convert(type, elm.content) + i+=1 + end + elseif hasmethod(parse, Tuple{type, String}) + for elm in elms + elms_typed[i] = parse(type, elm.content) + i+=1 + end + else + # should be the last to avoid invoking generic methods + for elm in elms + elms_typed[i] = type(elm) + i+=1 + end + end + return elms_typed +end From 32bb43b346edbb2f9421e9feffd79937e05478d2 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:41:33 -0500 Subject: [PATCH 05/13] findcontent --- src/xmlutils/extractors.jl | 368 ------------------------------------ src/xmlutils/findcontent.jl | 100 ++++++++++ 2 files changed, 100 insertions(+), 368 deletions(-) delete mode 100644 src/xmlutils/extractors.jl create mode 100644 src/xmlutils/findcontent.jl diff --git a/src/xmlutils/extractors.jl b/src/xmlutils/extractors.jl deleted file mode 100644 index 0ff54fa..0000000 --- a/src/xmlutils/extractors.jl +++ /dev/null @@ -1,368 +0,0 @@ -export findcontent -################################################################ -# Extractors -################################################################ -# Documents -################################################################ -function findcontent(::Type{T}, name::String, doc::Document, argAmlType::Type{<:AbsNode}) where {T} - findcontent(T, name, root(doc), argAmlType) -end - -# if no type is provided consider it to be Vector{Union{String, Nothing}} -function findcontent(name::String, doc::Document, argAmlType::Type{<:AbsNode}) - findcontent(Vector{Union{String, Nothing}}, name, root(doc), argAmlType) -end -################################################################ -# Nodes -################################################################ -# Single extraction -""" - - findcontent(type, element::String, node, argAmlType) - -Finds all the elements with the address of string in the node and converts to the passed type. - - findcontent(element::String, node, argAmlType) - -If no type is provided consider it to be Vector{Union{String, Nothing}} - -```julia -findcontent("instrument-name",node, AbsNormal) -findcontent(UInt8,"midi-channel",node, AbsNormal) -``` -""" -@transform function findcontent(::Type{T}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) where {T<:AbstractString} # Strings - - # if hasdocument(node) - # elm = findfirst(name,node) - # else - elm = findfirstlocal(name,node) - # end - - if isnothing(elm) # return nothing if nothing is found - return nothing - else - return elm.content - end -end - -function findcontent(::Type{T}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T<:AbstractString} - if haskey(node, name) - elm = node[name] - return elm - - else # return nothing if nothing is found - elm = nothing - return elm - end -end - -function findcontent(::Type{T}, indexstr::String, node::Node, argAmlType::Type{AbsText}) where {T<:AbstractString} - index = parse_textindex(indexstr) - elm = findtextlocal(index, node) - if isnothing(elm) # return nothing if nothing is found - return nothing - else - return elm.content - end -end - -# Number (and also Bool <:Number) -@transform function findcontent(::Type{T}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) where {T<:Number} - - # if hasdocument(node) - # elm = findfirst(name,node) - # else - elm = findfirstlocal(name,node) - # end - - if isnothing(elm) # return nothing if nothing is found - return nothing - else - return parse(T, elm.content) - end - -end - -function findcontent(::Type{T}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T<:Number} - if haskey(node, name) - elm = parse(T, node[name]) - return elm - - else # return nothing if nothing is found - elm = nothing - return elm - end -end - -function findcontent(::Type{T}, indexstr::String, node::Node, argAmlType::Type{AbsText}) where {T<:Number} - index = parse_textindex(indexstr) - elm = findtextlocal(index, node) - if isnothing(elm) # return nothing if nothing is found - return nothing - else - return parse(T, elm.content) - end -end - -# for defined types -function findcontent(::Type{T}, name::String,node::Node, argAmlType::Type{<:AbsNormal}) where {T} - - # if hasdocument(node) - # elm = findfirst(name,node) - # else - elm = findfirstlocal(name,node) - # end - - if isnothing(elm) # return nothing if nothing is found - return nothing - else - # TODO: better specialized method detection - # https://julialang.slack.com/archives/C6A044SQH/p1578442480438100 - if hasmethod(T, Tuple{String}) && Core.Compiler.return_type(T, Tuple{Node})=== Union{} - return T(elm.content) - else - return T(elm) - end - end - -end - - -function findcontent(::Type{T}, name::String,node::Node, argAmlType::Type{AbsAttribute}) where {T} - - if haskey(node, name) - elm = node[name] - return elm - - else # return nothing if nothing is found - elm = nothing - return elm - end - -end - -function findcontent(::Type{T}, indexstr::String,node::Node, argAmlType::Type{AbsText}) where {T} - index = parse_textindex(indexstr) - elm = findtextlocal(index, node) - if isnothing(elm) # return nothing if nothing is found - return nothing - else - # TODO: better specialized method detection - # https://julialang.slack.com/archives/C6A044SQH/p1578442480438100 - if hasmethod(T, Tuple{String}) && Core.Compiler.return_type(T, Tuple{Node})=== Union{} - return T(elm.content) - else - return T(elm) - end - end -end - -# Union with Nothing -@transform function findcontent(::Type{UN{T}}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) where {T} - return findcontent(T, name, node, argAmlType) -end - -# Nothing Alone -@transform function findcontent(::Type{Nothing}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) - return nothing -end - -################################################################ -# Vector extraction - -# String -@transform function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) where {T<:AbstractString} - - # if hasdocument(node) - # elmsNode = findall(name, node) # a vector of Node elements - # else - elmsNode = findalllocal(name, node) # a vector of Node elements - # end - - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=elm.content - end - return elmsType - end -end - -function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T<:AbstractString} - if haskey(node, name) - elmsNode = node[name] - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=elm - end - return elmsType - else # return nothing if nothing is found - elmsNode = nothing - end -end - -function findcontent(::Type{Vector{T}}, indicesstr::String, node::Node, argAmlType::Type{AbsText}) where {T<:AbstractString} - indices = parse_textindices(indicesstr) - elmsNode = findvecttextlocal(indices, node) - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=elm.content - end - return elmsType - end -end - -# Number (and also Bool <:Number) -@transform function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) where {T<:Number} - - # if hasdocument(node) - # elmsNode = findall(name, node) # a vector of Node elements - # else - elmsNode = findalllocal(name, node) # a vector of Node elements - # end - - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=parse(T, elm.content) - end - return elmsType - end -end - -function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T<:Number} - if haskey(node, name) - elmsNode = parse(T, node[name]) - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=parse(T, elm) - end - return elmsType - else # return nothing if nothing is found - elmsNode = nothing - end -end - -function findcontent(::Type{Vector{T}}, indicesstr::String, node::Node, argAmlType::Type{AbsText}) where {T<:Number} - indices = parse_textindices(indicesstr) - elmsNode = findvecttextlocal(indices, node) - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=parse(T, elm.content) - end - return elmsType - end -end - - -# for defined types -function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{<:AbsNormal}) where{T} - - # if hasdocument(node) - # elmsNode = findall(name, node) # a vector of Node elements - # else - elmsNode = findalllocal(name, node) # a vector of Node elements - # end - - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - if hasmethod(T, Tuple{String}) && Core.Compiler.return_type(T, Tuple{Node}) === Union{} - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=T(elm.content) - end - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=T(elm) - end - end - return elmsType - end - -end -function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where{T} - - if haskey(node, name) - elmsNode = node[name] - else # return nothing if nothing is found - elmsNode = nothing - end - - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - if hasmethod(T, Tuple{String}) && Core.Compiler.return_type(T, Tuple{Node}) === Union{} - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=T(elm.content) - end - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=T(elm) - end - end - return elmsType - end - -end - -function findcontent(::Type{Vector{T}}, indicesstr::String, node::Node, argAmlType::Type{AbsText}) where{T} - indices = parse_textindices(indicesstr) - elmsNode = findvecttextlocal(indices, node) - if isnothing(elmsNode) # return nothing if nothing is found - return nothing - else - if hasmethod(T, Tuple{String}) && Core.Compiler.return_type(T, Tuple{Node}) === Union{} - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=T(elm.content) - end - else - elmsType = Vector{T}(undef, length(elmsNode)) # a vector of Type elements - for (i, elm) in enumerate(elmsNode) - elmsType[i]=T(elm) - end - end - return elmsType - end -end - -# Union with Nothing -@transform function findcontent(::Type{Vector{UN{T}}}, name::String,node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) where {T} - return findcontent(Vector{T},name,node, argAmlType) -end - -# Nothing Alone -@transform function findcontent(::Type{Vector{Nothing}}, name::String,node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) - return nothing -end - -# vector of Any - consider it to be string -@transform function findcontent(::Type{Vector{Any}}, name::String,node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) - return findcontent(Vector{String},name,node, argAmlType) -end - -# if no type is provided consider it to be Vector{Union{String, Nothing}} -@transform function findcontent(name::String, node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) - return findcontent(Vector{Union{String, Nothing}},name, node, argAmlType) -end - -################################################################ -# Dict Extraction -function findcontent(::Type{AbstractDict}, name, node, argAmlType) - throw(MethodError("Dicts are not supported for extraction/updating")) -end diff --git a/src/xmlutils/findcontent.jl b/src/xmlutils/findcontent.jl new file mode 100644 index 0000000..69a8b8c --- /dev/null +++ b/src/xmlutils/findcontent.jl @@ -0,0 +1,100 @@ +export findcontent +################################################################ +# Content Extractor +################################################################ +# Documents +################################################################ +function findcontent(::Type{T}, name::String, doc::Document, argAmlType::Type{<:AbsNode}) where {T} + findcontent(T, name, root(doc), argAmlType) +end + +# if no type is provided consider it to be Vector{Union{String, Nothing}} +function findcontent(name::String, doc::Document, argAmlType::Type{<:AbsNode}) + findcontent(Vector{Union{String, Nothing}}, name, root(doc), argAmlType) +end +################################################################ +# Nodes +################################################################ +# Single extraction + +""" + + findcontent(type, element::String, node, argAmlType) + +Finds all the elements with the address of string in the node and converts to the passed type. + + findcontent(element::String, node, argAmlType) + +If no type is provided consider it to be Vector{Union{String, Nothing}} + +```julia +findcontent("instrument-name",node, AbsNormal) +findcontent(UInt8,"midi-channel",node, AbsNormal) +``` +""" +function findcontent(::Type{T}, name::String, node::Node, argAmlType::Type{<:AbsNode}) where {T} + elm = findfirst(name, node, argAmlType) + if isnothing(elm) # return nothing if nothing is found + return nothing + else + return nodeparse(T, elm) + end +end + +# Union with Nothing +@transform function findcontent(::Type{UN{T}}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) where {T} + return findcontent(T, name, node, argAmlType) +end + +# Nothing Alone +@transform function findcontent(::Type{Nothing}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) + return nothing +end + +################################################################ +# Vector extraction + +function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{<:Union{AbsNormal, AbsText}}) where{T} + elms = findall(name, node, argAmlType) + if isnothing(elms) # return nothing if nothing is found + return nothing + else + return nodeparse(T, elms) + end +end + +# Fast attribute extractor +function findcontent(::Type{Vector{T}}, name::String, node::Node, argAmlType::Type{<:Union{AbsAttribute}}) where{T} + if haskey(node, name) + elms = node[name] + return nodeparse(T, elms) + else # return nothing if nothing is found + return nothing + end +end + +# Union with Nothing +@transform function findcontent(::Type{Vector{UN{T}}}, name::String,node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) where {T} + return findcontent(Vector{T},name,node, argAmlType) +end + +# Nothing Alone +@transform function findcontent(::Type{Vector{Nothing}}, name::String,node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) + return nothing +end + +# vector of Any - consider it to be string +@transform function findcontent(::Type{Vector{Any}}, name::String,node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) + return findcontent(Vector{String},name,node, argAmlType) +end + +# if no type is provided consider it to be Vector{Union{String, Nothing}} +@transform function findcontent(name::String, node::Node, argAmlType::Type{allsubtypes(AbsDocOrNode)}) + return findcontent(Vector{Union{String, Nothing}}, name, node, argAmlType) +end + +################################################################ +# Dict Extraction +function findcontent(::Type{AbstractDict}, name, node, argAmlType) + throw(MethodError("Dicts are not supported for extraction/updating")) +end From b1a78726f4c886ba0b7ded49d5af8e4e4681c369 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:41:45 -0500 Subject: [PATCH 06/13] updater --- src/xmlutils/updater.jl | 126 +++++++++++++++++++ src/xmlutils/updaters.jl | 253 --------------------------------------- 2 files changed, 126 insertions(+), 253 deletions(-) create mode 100644 src/xmlutils/updater.jl delete mode 100644 src/xmlutils/updaters.jl diff --git a/src/xmlutils/updater.jl b/src/xmlutils/updater.jl new file mode 100644 index 0000000..66e5aa1 --- /dev/null +++ b/src/xmlutils/updater.jl @@ -0,0 +1,126 @@ +export updatecontent! +################################################################ +# Updaters +################################################################ +# Update based on the elm +################################################################ +# Nothing remove +""" + updatecontent!(value, elm::Node|Nothing, node, argAmlType) + updatecontent!(value, elms::Vector{Node|Nothing}, node, argAmlType) + +In the given `node`, update the content of all the given `elm` or `elms` to `value`. + + updatecontent!(value, name::String, node, argAmlType) + +In the given `node`, update the content of all the elements with given `name` to `value`. +""" +function updatecontent!(value::Nothing, elm::Node, node::Node, argAmlType::Type) + unlink!(elm) +end + +# Nothing Nothing +function updatecontent!(value::Nothing, elm::Nothing, node::Node, argAmlType::Type) + # nothing +end + +################################################################ +# Number and String +function updatecontent!(value::T, elm::Node, node::Node, argAmlType::Type) where {T<:Union{AbstractString, Number}} + elm.content = value +end + +# Number and String Vector +function updatecontent!(values::Vector{T}, elms::Vector{Node}, node::Node, argAmlType::Type) where {T<:Union{AbstractString, Number}} + for (i, elm) in enumerate(elms) + elm.content = values[i] + end +end + +################################################################ +# General Type +function updatecontent!(value::T, elm::Node, node::Node, argAmlType::Type) where {T} + if hasmethod(string, Tuple{T}) + elm.content = string(value) + else + unlink!(elm) + link!(node, value.aml) + end +end + +# General Type Vector +function updatecontent!(values::Vector{T}, elms::Vector{Node}, node::Node, argAmlType::Type) where {T} + for (i, elm) in enumerate(elms) + if isnothing(values[i]) + unlink!(elm) + else + if hasmethod(string, Tuple{T}) + elm.content = string(values[i]) + else + unlink!(elm) + link!(node, values[i].aml) + end + end + end +end + +################################################################ +# Update based on the name +################################################################ +# Documents +function updatecontent!(value, name::String, doc::Document, argAmlType::Type{<:AbsNode}) + updatecontent!(value, name, root(doc), argAmlType) +end +################################################################ +# Nodes +# Single Updater + +function updatecontent!(value, name::String, node::Node, argAmlType::Type{<:Union{AbsNormal, AbsText}}) + elm = findfirst(name, node, argAmlType) + if !isnothing(elm) + updatecontent!(value, elm, node, argAmlType) + else + # addelm! if nothing is found + addelm!(node, name, value, argAmlType) + end +end + +# Fast attribute updater +function updatecontent!(value, name::String, node::Node, argAmlType::Type{<:AbsAttribute}) + if haskey(node, name) + node[name] = value + else + # addelm! if nothing is found + addelm!(node, name, value, argAmlType) + end +end + + +################################################################ +# Vector update + +function updatecontent!(values::Vector, name::String, node::Node, argAmlType::Type{<:Union{AbsNormal, AbsText}}) + elms = findall(name, node, argAmlType) + if !isnothing(elms) + updatecontent!(values, elms, node, argAmlType) + else + # addelm! if nothing is found + addelm!(node, name, values, argAmlType) + end +end + +# Fast attribute updater +function updatecontent!(values::Vector, name::String, node::Node, argAmlType::Type{<:AbsAttribute}) + if haskey(node, name) + node[name] .= values + else + # addelm! if nothing is found + addelm!(node, name, values, argAmlType) + end +end + +################################################################ +# Dict Updating +function updatecontent!(value::Type{AbstractDict}, name::Union{Node, String, Nothing}, node::Union{Node, Document}, argAmlType::Type{<:AbsNode}) + throw(MethodError("Dicts are not supported for extraction/updating")) +end diff --git a/src/xmlutils/updaters.jl b/src/xmlutils/updaters.jl deleted file mode 100644 index 5a33c02..0000000 --- a/src/xmlutils/updaters.jl +++ /dev/null @@ -1,253 +0,0 @@ -export updatecontent! -################################################################ -# Updaters -################################################################ -# Documents -function updatecontent!(value, name::String, doc::Document, argAmlType::Type{<:AbsNode}) - updatecontent!(value, name, root(doc), argAmlType) -end -################################################################ -# Nodes -# Single Updater - -# for String, Number and bool -""" - updatecontent!(value, element::String, node, argAmlType) - -Finds all the elements with the address of string in the node, and updates the content. -""" -@transform function updatecontent!(value::T, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) where {T<:Union{AbstractString, Number}} - # if hasdocument(node) - # elm = findfirst(name, node) - # else - elm = findfirstlocal(name, node) - # end - - if isnothing(elm) # error if nothing is found - return error("field not found in aml") - else - elm.content = value - end -end - -function updatecontent!(value::T, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T<:Union{AbstractString, Number}} - if haskey(node, name) - node[name] = value - - else # error if nothing is found - return error("field not found in aml") - end -end - -function updatecontent!(value::T, indexstr::String, node::Node, argAmlType::Type{AbsText}) where {T<:Union{AbstractString, Number}} - index = parse_textindex(indexstr) - elm = findtextlocal(index, node) - if isnothing(elm) # return nothing if nothing is found - return error("field not found in aml") - else - elm.content = value - end -end - -# Defined types -function updatecontent!(value::T, name::String, node::Node, argAmlType::Type{<:AbsNormal}) where {T} - # if hasdocument(node) - # elm = findfirst(name,node) - # else - elm = findfirstlocal(name,node) - # end - - if isnothing(elm) # error if nothing is found - return error("field not found in aml") - else - if hasmethod(string, Tuple{T}) - elm.content = string(value) - else - unlink!(elm) - link!(node, value.aml) - end - end -end - -function updatecontent!(value::T, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T} - if haskey(node, name) - elm = node[name] - unlink!(elm) - link!(node, value.aml) - - else # error if nothing is found - return error("field not found in aml") - end -end - -function updatecontent!(value::T, indexstr::String, node::Node, argAmlType::Type{AbsText}) where {T} - index = parse_textindex(indexstr) - elm = findtextlocal(index, node) - if isnothing(elm) # error if nothing is found - return error("field not found in aml") - else - if hasmethod(string, Tuple{T}) - elm.content = string(value) - else - unlink!(elm) - link!(node, value.aml) - end - end -end - -# Nothing Alone -@transform function updatecontent!(value::Nothing, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) - # if hasdocument(node) - # elm = findfirst(name,node) - # else - elm = findfirstlocal(name,node) - # end - - if isnothing(elm) # error if nothing is found - return error("field not found in aml") - else - unlink!(elm) - end -end - -function updatecontent!(value::Nothing, name::String,node::Node, argAmlType::Type{AbsAttribute}) - if haskey(node, name) - elm = node[name] - unlink!(elm) - - else # error if nothing is found - return error("field not found in aml") - end -end - -function updatecontent!(value::Nothing, indexstr::String, node::Node, argAmlType::Type{AbsText}) - index = parse_textindex(indexstr) - elm = findtextlocal(index, node) - if isnothing(elm) # error if nothing is found - return error("field not found in aml") - else - unlink!(elm) - end -end -################################################################ -# Vector update - -@transform function updatecontent!(value::Vector{T}, name::String, node::Node, argAmlType::Type{allsubtypes(AbsNormal)}) where {T<:Union{AbstractString, Number}} - # if hasdocument(node) - # elmsNode = findall(name, node) # a vector of Node elements - # else - elmsNode = findalllocal(name, node) # a vector of Node elements - # end - - if isnothing(elmsNode) # error if nothing is found - return error("field not found in aml") - else - for (i, elm) in enumerate(elmsNode) - elm.content = value[i] - end - end -end - -function updatecontent!(value::Vector{T}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where {T<:Union{AbstractString, Number}} - if haskey(node, name) - elmsNode = node[name] - for (i, elm) in enumerate(elmsNode) - elm.content = value[i] - end - else # error if nothing is found - return error("field not found in aml") - end -end - -function updatecontent!(value::Vector{T}, indicesstr::String, node::Node, argAmlType::Type{AbsText}) where {T<:Union{AbstractString, Number}} - indices = parse_textindices(indicesstr) - elmsNode = findvecttextlocal(indices, node) - if isnothing(elmsNode) # error if nothing is found - return error("field not found in aml") - else - for (i, elm) in enumerate(elmsNode) - elm.content = value[i] - end - end -end - -# for defined types and nothing -function updatecontent!(value::Vector{T}, name::String, node::Node, argAmlType::Type{<:AbsNormal}) where{T} - - # if hasdocument(node) - # elmsNode = findall(name, node) # a vector of Node elements - # else - elmsNode = findalllocal(name, node) # a vector of Node elements - # end - - if isnothing(elmsNode) # error if nothing is found - return error("field not found in aml") - else - for (i, elm) in enumerate(elmsNode) - if isnothing(value[i]) - unlink!(elm) - else - if hasmethod(string, Tuple{T}) - elm.content = string(value[i]) - else - unlink!(elm) - link!(node, value[i].aml) - end - end - end - end - -end - - -function updatecontent!(value::Vector{T}, name::String, node::Node, argAmlType::Type{AbsAttribute}) where{T} - if haskey(node, name) - elmsNode = node[name] - else # error if nothing is found - return error("field not found in aml") - end - - if isnothing(elmsNode) # error if nothing is found - return error("field not found in aml") - else - for (i, elm) in enumerate(elmsNode) - if isnothing(value[i]) - unlink!(elm) - else - if hasmethod(string, Tuple{T}) - elm.content = string(value[i]) - else - unlink!(elm) - link!(node, value[i].aml) - end - end - end - end -end - -function updatecontent!(value::Vector{T}, indicesstr::String, node::Node, argAmlType::Type{AbsText}) where{T} - indices = parse_textindices(indicesstr) - elmsNode = findvecttextlocal(indices, node) - if isnothing(elmsNode) # error if nothing is found - return error("field not found in aml") - else - for (i, elm) in enumerate(elmsNode) - if isnothing(value[i]) - unlink!(elm) - else - if hasmethod(string, Tuple{T}) - elm.content = string(value[i]) - else - unlink!(elm) - link!(node, value[i].aml) - end - end - end - end - -end -################################################################ -# Dict Updating -function updatecontent!(value::Type{AbstractDict}, name, node, argAmlType) - throw(MethodError("Dicts are not supported for extraction/updating")) -end From 3474629d636a66662ee8eef5a0af015a8a71cb0f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:41:59 -0500 Subject: [PATCH 07/13] include new files --- src/xmlutils.jl | 11 ++++++----- src/xmlutils/aml_type_support.jl | 4 ---- 2 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 src/xmlutils/aml_type_support.jl diff --git a/src/xmlutils.jl b/src/xmlutils.jl index 6249fa1..4f94bbc 100644 --- a/src/xmlutils.jl +++ b/src/xmlutils.jl @@ -17,11 +17,12 @@ import EzXML: Document, Node ################################################################ import Tables # DataTypesSupport -include("xmlutils/aml_type_support.jl") +include("xmlutils/TypesSupport/amlTables.jl") ################################################################ include("xmlutils/initializer.jl") -include("xmlutils/creators.jl") -include("xmlutils/extractor_utils.jl") -include("xmlutils/extractors.jl") -include("xmlutils/updaters.jl") +include("xmlutils/addnode.jl") +include("xmlutils/nodeparse.jl") +include("xmlutils/findnode.jl") +include("xmlutils/findcontent.jl") +include("xmlutils/updater.jl") ################################################################ diff --git a/src/xmlutils/aml_type_support.jl b/src/xmlutils/aml_type_support.jl deleted file mode 100644 index a29fc63..0000000 --- a/src/xmlutils/aml_type_support.jl +++ /dev/null @@ -1,4 +0,0 @@ -export aml -import EzXML.parsehtml - -include("TypesSupport/amlTables.jl") From fab7bbbf673f3963fd4623e733b39f1f36d62197 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:42:15 -0500 Subject: [PATCH 08/13] Base.findfirst and findall --- src/@aml/@aml_parse.jl | 2 +- src/xmlutils/TypesSupport/amlTables.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@aml/@aml_parse.jl b/src/@aml/@aml_parse.jl index df6b2cd..9df53ab 100644 --- a/src/@aml/@aml_parse.jl +++ b/src/@aml/@aml_parse.jl @@ -18,7 +18,7 @@ function aml_parse(expr::Expr) argsexpr = expr.args[3] # arguments of the type # TODO: optimize and fuse these - areargs_inds = findall(x->!(isa(x, LineNumberNode)), argsexpr.args) + areargs_inds = Base.findall(x->!(isa(x, LineNumberNode)), argsexpr.args) macronum = count(x-> isa(x, Tuple{Symbol, Expr}), argsexpr.args) data = argsexpr.args[areargs_inds] diff --git a/src/xmlutils/TypesSupport/amlTables.jl b/src/xmlutils/TypesSupport/amlTables.jl index 67f0a32..0635049 100644 --- a/src/xmlutils/TypesSupport/amlTables.jl +++ b/src/xmlutils/TypesSupport/amlTables.jl @@ -6,7 +6,7 @@ function amlTable(x) pretty_table(io, x, backend = :html, standalone = false) str = String(resize!(io.data, io.size)) - html = findfirst("html/body/table",parsehtml(str)) + html = Base.findfirst("html/body/table",parsehtml(str)) unlink!(html) return html end From 299a7395367c731e1941244d21c62db00f356ab4 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:42:28 -0500 Subject: [PATCH 09/13] benchmark result --- benchmark/bench.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/benchmark/bench.jl b/benchmark/bench.jl index 16e8bd3..f424cbb 100644 --- a/benchmark/bench.jl +++ b/benchmark/bench.jl @@ -84,6 +84,13 @@ P1, P2, U = creation(); #= Benchmark Result +v 0.10 +# small bump in extraction is because of two additional hasmethod check in nodeparse. Using traits this will be fixed + +8.899 μs (100 allocations: 3.61 KiB) +3.938 μs (66 allocations: 3.17 KiB) +308.500 μs (403 allocations: 16.33 KiB) + V 0.9.2 - julia 1.4 10.000 μs (99 allocations: 3.39 KiB) From a75bcb3174e3e767cacca1c91af3dac50bbaa16d Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:53:39 -0500 Subject: [PATCH 10/13] domxpath doc --- docs/make.jl | 8 ++--- docs/src/customConstructors.md | 59 ------------------------------- docs/src/domxpath.md | 64 ++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 64 deletions(-) create mode 100644 docs/src/domxpath.md diff --git a/docs/make.jl b/docs/make.jl index 2a48aae..2e2d537 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -13,14 +13,12 @@ makedocs(; ), pages=[ "Home" => "index.md", - - "Value Checking" => "valueChecking.md", "Supported Value Types" => "supportedValueTypes.md", + "Value Checking" => "valueChecking.md", "Extra Contructors" => "extraConstructors.md", - "Custom Value Types" => "customValueTypes.md", - "Custom Contructors - AcuteML Backend" => "customConstructors.md", - + "Custom Contructors" => "customConstructors.md", + "DOM/XPath API" => "domxpath.md", "Templating" => "templating.md", "Syntax Reference" => "SyntaxReference.md" ], diff --git a/docs/src/customConstructors.md b/docs/src/customConstructors.md index 795149c..11c449a 100644 --- a/docs/src/customConstructors.md +++ b/docs/src/customConstructors.md @@ -110,62 +110,3 @@ mathclass = MathClass(xml) mathclass.students[2].log # "A genius with a GPA of 5.0 is found" ``` - -## Making a Type and constructor from scratch using AcuteML Backend - -You can use AcuteML utilities to define custom type constructors from scratch or to override `@aml` defined constructors. - -Notice that if you don't use `@aml`, you should include `aml::Node` as one of your fields. - -Functions to use for custom html/xml constructor: -- [initialize_node](@ref): function to initialize the aml -- [addelm!](@ref) : to add elements (single or a vector of elements) -Use these functions, to make a method that calculates the `aml` inside the function and returns all of the fields. - -Functions to use for custom html/xml extractor: -- [findcontent](@ref) : to extract elements -Use these functions, to make a method that gets the `aml::Node` and calculates and returns all of the fields. - -Functions to support mutability: -- [updatecontent!](@ref): Finds all the elements with the address of string in the node, and updates the content. - -# Example: -In this example we define `Identity` with custom constructors: -```julia -using AcuteML - -mutable struct Identity - pitch::UN{Pitch} - rest::UN{Rest} - unpitched::UN{Unpitched} - aml::Node -end - -function Identity(;pitch = nothing, rest = nothing, unpitched = nothing) - - # This constructor only allows one the fields to exist - similar to choice element in XS - - aml = initialize_node(AbsNormal, "identity") - - if pitch != nothing - addelm!(aml, "pitch", pitch, AbsNormal) - elseif rest != nothing - addelm!(aml, "rest", rest, AbsNormal) - elseif unpitched != nothing - addelm!(aml, "unpitched", unpitched, AbsNormal) - else - error("one of the pitch, rest or unpitched should be given") - end - - return Identity(pitch, rest, unpitched, aml) -end - -function Identity(;aml) - - pitch = findcontent(Pitch, "pitch", aml, AbsNormal) - rest = findcontent(Rest, "rest", aml, AbsNormal) - unpitched = findcontent(Unpitched, "unpitched", aml, AbsNormal) - - return Identity(pitch, rest, unpitched, aml) -end -``` diff --git a/docs/src/domxpath.md b/docs/src/domxpath.md new file mode 100644 index 0000000..f538eab --- /dev/null +++ b/docs/src/domxpath.md @@ -0,0 +1,64 @@ +# AcuteML DOM/Xpath API + +AcuteML provides a DOM/Xpath API that you can use to do lower level XML/HTML manipulation if needed. + +You can use AcuteML utilities to define custom type constructors from scratch or to override `@aml` defined constructors. + +Notice that if you don't use `@aml`, you should include `aml::Node` as one of your fields. + +Functions to use for custom html/xml constructor: +- [createnode](@ref): function to create a node/document +- [addnode!](@ref) : To add nodes (single or a vector of nodes) as a child of given a node/document. +Use these functions, to make a method that calculates the `aml` inside the function and returns all of the fields. + +Functions to use for custom html/xml extractor: +- [findfirst](@ref): to find the first node based on the given node name +- [findall](@ref): to find all of the nodes based on the given node name +- [findcontent](@ref) : to get the content of a node based on the given name +Use these functions, to make a method that gets the `aml::Node` and calculates and returns all of the fields. + +Functions to support mutability: +- [updatecontent!](@ref): Finds all the elements with the address of string in the node, and updates the content. + +## Making a Type and constructor from scratch using AcuteML Backend + +# Example: +In this example we define `Identity` with custom constructors: +```julia +using AcuteML + +mutable struct Identity + pitch::UN{Pitch} + rest::UN{Rest} + unpitched::UN{Unpitched} + aml::Node +end + +function Identity(;pitch = nothing, rest = nothing, unpitched = nothing) + + # This constructor only allows one the fields to exist - similar to choice element in XS + + aml = createnode(AbsNormal, "identity") + + if pitch != nothing + addnode!(aml, "pitch", pitch, AbsNormal) + elseif rest != nothing + addnode!(aml, "rest", rest, AbsNormal) + elseif unpitched != nothing + addnode!(aml, "unpitched", unpitched, AbsNormal) + else + error("one of the pitch, rest or unpitched should be given") + end + + return Identity(pitch, rest, unpitched, aml) +end + +function Identity(;aml) + + pitch = findcontent(Pitch, "pitch", aml, AbsNormal) + rest = findcontent(Rest, "rest", aml, AbsNormal) + unpitched = findcontent(Unpitched, "unpitched", aml, AbsNormal) + + return Identity(pitch, rest, unpitched, aml) +end +``` From eb455142f7b885dee423c13372fc1c405ace9d81 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:54:11 -0500 Subject: [PATCH 11/13] rename addelm! -> addnode! / initialize_node -> createnode --- .../precompile/precompile_AcuteML.jl | 30 +++---- src/@aml/@aml_create.jl | 2 +- src/@aml/@aml_create/get_arg_xml_.jl | 4 +- src/xmlutils/addnode.jl | 50 +++++------ src/xmlutils/initializer.jl | 14 +-- src/xmlutils/updater.jl | 16 ++-- test/xmlutils.jl | 88 +++++++++---------- 7 files changed, 102 insertions(+), 102 deletions(-) diff --git a/deps/SnoopCompile/precompile/precompile_AcuteML.jl b/deps/SnoopCompile/precompile/precompile_AcuteML.jl index 95690a5..f25c33b 100644 --- a/deps/SnoopCompile/precompile/precompile_AcuteML.jl +++ b/deps/SnoopCompile/precompile/precompile_AcuteML.jl @@ -11,17 +11,17 @@ function _precompile_() precompile(Tuple{typeof(AcuteML.multiString),Float64}) precompile(Tuple{typeof(AcuteML.multiString),Int64}) precompile(Tuple{typeof(AcuteML.multiString),String}) - precompile(Tuple{typeof(addelm!),Document,String,Nothing,Type{AbsAttribute}}) - precompile(Tuple{typeof(addelm!),Node,String,Array{Any,1},Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,Array{Float64,1},Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,Array{Int64,1},Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,Array{String,1},Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,Float64,Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,Int64,Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,Nothing,Type{AbsAttribute}}) - precompile(Tuple{typeof(addelm!),Node,String,Nothing,Type{AbsNormal}}) - precompile(Tuple{typeof(addelm!),Node,String,String,Type{AbsAttribute}}) - precompile(Tuple{typeof(addelm!),Node,String,String,Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Document,String,Nothing,Type{AbsAttribute}}) + precompile(Tuple{typeof(addnode!),Node,String,Array{Any,1},Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,Array{Float64,1},Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,Array{Int64,1},Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,Array{String,1},Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,Float64,Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,Int64,Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,Nothing,Type{AbsAttribute}}) + precompile(Tuple{typeof(addnode!),Node,String,Nothing,Type{AbsNormal}}) + precompile(Tuple{typeof(addnode!),Node,String,String,Type{AbsAttribute}}) + precompile(Tuple{typeof(addnode!),Node,String,String,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),Type{Array{Any,1}},String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),Type{Array{Float64,1}},String,Node,Type{AbsNormal}}) @@ -31,10 +31,10 @@ function _precompile_() precompile(Tuple{typeof(findcontent),Type{String},String,Node,Type{AbsAttribute}}) precompile(Tuple{typeof(findcontent),Type{String},String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),Type{Union{Nothing, String}},String,Node,Type{AbsAttribute}}) - precompile(Tuple{typeof(initialize_node),Type{AbsEmpty},String}) - precompile(Tuple{typeof(initialize_node),Type{AbsHtml},String}) - precompile(Tuple{typeof(initialize_node),Type{AbsNormal},String}) - precompile(Tuple{typeof(initialize_node),Type{AbsXml},String}) + precompile(Tuple{typeof(createnode),Type{AbsEmpty},String}) + precompile(Tuple{typeof(createnode),Type{AbsHtml},String}) + precompile(Tuple{typeof(createnode),Type{AbsNormal},String}) + precompile(Tuple{typeof(createnode),Type{AbsXml},String}) precompile(Tuple{typeof(newTemplate),String,Symbol}) precompile(Tuple{typeof(newTemplate),String}) precompile(Tuple{typeof(updatecontent!),Array{Any,1},String,Node,Type{AbsNormal}}) diff --git a/src/@aml/@aml_create.jl b/src/@aml/@aml_create.jl index 17a4dcf..9584652 100644 --- a/src/@aml/@aml_create.jl +++ b/src/@aml/@aml_create.jl @@ -94,7 +94,7 @@ function aml_create(expr::Expr, args_param, args_defaultvalue, args_type, args_v error("Invalid usage of @aml") end ################################################################ - node_initializer = :( aml = initialize_node($struct_nodetype, $struct_name) ) + node_initializer = :( aml = createnode($struct_nodetype, $struct_name) ) struct_definition =:($expr) diff --git a/src/@aml/@aml_create/get_arg_xml_.jl b/src/@aml/@aml_create/get_arg_xml_.jl index 92d55aa..df032e8 100644 --- a/src/@aml/@aml_create/get_arg_xml_.jl +++ b/src/@aml/@aml_create/get_arg_xml_.jl @@ -9,13 +9,13 @@ function get_arg_xmlcreator(argcustomcreator, has_arg_xmlchecker::Bool, argtype, if !has_arg_xmlchecker arg_creator = quote $(esc(argcustomcreator)) - addelm!(aml, $argname, $esc_argvar, $argliteraltype) + addnode!(aml, $argname, $esc_argvar, $argliteraltype) end else arg_creator=quote $(esc(argcustomcreator)) if isnothing($esc_argvar) || ($esc_argfunction)($esc_argvar) - addelm!(aml, $argname, $esc_argvar, $argliteraltype) + addnode!(aml, $argname, $esc_argvar, $argliteraltype) else error("$($argname) doesn't meet criteria function") end diff --git a/src/xmlutils/addnode.jl b/src/xmlutils/addnode.jl index a5b8170..8434f7b 100644 --- a/src/xmlutils/addnode.jl +++ b/src/xmlutils/addnode.jl @@ -1,4 +1,4 @@ -export addelm! +export addnode! ################################################################ # Add node ################################################################ @@ -6,15 +6,15 @@ export addelm! ################################################################ # Any """ - addelm!(node, name, value, argAmlType) + addnode!(node, name, value, argAmlType) -Add one element to a node/document +To add nodes (single or a vector of nodes) as a child of given a node/document. """ -function addelm!(aml::Document, name::String, value::T, argAmlType::Type{<:AbsDocOrNode}) where {T} +function addnode!(aml::Document, name::String, value::T, argAmlType::Type{<:AbsDocOrNode}) where {T} if hasroot(aml) amlNode = root(aml) - elm = addelm!(amlNode, name, value, argAmlType) + elm = addnode!(amlNode, name, value, argAmlType) return elm elseif hasfield(T, :aml) elm = setroot!(aml, value.aml) @@ -26,22 +26,22 @@ function addelm!(aml::Document, name::String, value::T, argAmlType::Type{<:AbsDo end # Nothing -function addelm!(aml::Document, name::String, value::Nothing, argAmlType::Type{<:AbsDocOrNode}) +function addnode!(aml::Document, name::String, value::Nothing, argAmlType::Type{<:AbsDocOrNode}) # do nothing if value is nothing end ################################################################ # Vector """ - addelm!(node, name, value, argAmlType) + addnode!(node, name, value, argAmlType) Add a vector to a node/document ``` """ -function addelm!(aml::Document, name::String, value::Vector, argAmlType::Type{<:AbsDocOrNode}) +function addnode!(aml::Document, name::String, value::Vector, argAmlType::Type{<:AbsDocOrNode}) if hasroot(aml) amlNode = root(aml) - elm = addelm!(amlNode, name, value, argAmlType) + elm = addnode!(amlNode, name, value, argAmlType) return elm else error("You cannot insert a vector in the document directly. Define a @aml defined field for xml or html document struct") @@ -53,21 +53,21 @@ end # Nodes ################################################################ # String -@transform function addelm!(aml::Node, name::String,value::AbstractString, argAmlType::Type{allsubtypes(AbsNormal)}) +@transform function addnode!(aml::Node, name::String,value::AbstractString, argAmlType::Type{allsubtypes(AbsNormal)}) if !isnothing(value) # do nothing if value is nothing elm = addelement!(aml, name, value) return elm end end -function addelm!(aml::Node, name::String,value::AbstractString, argAmlType::Type{AbsAttribute}) +function addnode!(aml::Node, name::String,value::AbstractString, argAmlType::Type{AbsAttribute}) if !isnothing(value) # do nothing if value is nothing elm = link!(aml, AttributeNode(name, value)) return elm end end -function addelm!(aml::Node, indexstr::String,value::AbstractString, argAmlType::Type{AbsText}) +function addnode!(aml::Node, indexstr::String,value::AbstractString, argAmlType::Type{AbsText}) index = parse_textindex(indexstr) if index < length(elements(aml)) desired_node = elements(aml)[index] @@ -85,21 +85,21 @@ function addelm!(aml::Node, indexstr::String,value::AbstractString, argAmlType:: end # Number (and also Bool <:Number) -@transform function addelm!(aml::Node, name::String, value::Number, argAmlType::Type{allsubtypes(AbsNormal)}) +@transform function addnode!(aml::Node, name::String, value::Number, argAmlType::Type{allsubtypes(AbsNormal)}) if !isnothing(value) # do nothing if value is nothing elm = addelement!(aml, name, string(value)) return elm end end -function addelm!(aml::Node, name::String, value::Number, argAmlType::Type{AbsAttribute}) +function addnode!(aml::Node, name::String, value::Number, argAmlType::Type{AbsAttribute}) if !isnothing(value) # do nothing if value is nothing elm = link!(aml, AttributeNode(name, string(value))) return elm end end -function addelm!(aml::Node, indexstr::String, value::Number, argAmlType::Type{AbsText}) +function addnode!(aml::Node, indexstr::String, value::Number, argAmlType::Type{AbsText}) index = parse_textindex(indexstr) if index < length(elements(aml)) desired_node = elements(aml)[index] @@ -117,7 +117,7 @@ function addelm!(aml::Node, indexstr::String, value::Number, argAmlType::Type{Ab end # Other -function addelm!(aml::Node, name::String, value::T, argAmlType::Type{<:AbsNormal}) where {T} +function addnode!(aml::Node, name::String, value::T, argAmlType::Type{<:AbsNormal}) where {T} if hasfield(T, :aml) elm = link!(aml,value.aml) return elm @@ -137,7 +137,7 @@ function addelm!(aml::Node, name::String, value::T, argAmlType::Type{<:AbsNormal end end -function addelm!(aml::Node, name::String, value::T, argAmlType::Type{AbsAttribute}) where {T} +function addnode!(aml::Node, name::String, value::T, argAmlType::Type{AbsAttribute}) where {T} if hasfield(T, :aml) elm = link!(aml, AttributeNode(name, value.aml)) return elm @@ -157,7 +157,7 @@ function addelm!(aml::Node, name::String, value::T, argAmlType::Type{AbsAttribut end end -function addelm!(aml::Node, indexstr::String, value::T, argAmlType::Type{AbsText}) where {T} +function addnode!(aml::Node, indexstr::String, value::T, argAmlType::Type{AbsText}) where {T} index = parse_textindex(indexstr) if index < length(elements(aml)) @@ -203,7 +203,7 @@ function addelm!(aml::Node, indexstr::String, value::T, argAmlType::Type{AbsText end # Nothing -@transform function addelm!(aml::Node, name::String, value::Nothing, argAmlType::Type{allsubtypes(AbsDocOrNode)}) +@transform function addnode!(aml::Node, name::String, value::Nothing, argAmlType::Type{allsubtypes(AbsDocOrNode)}) # do nothing end ################################################################ @@ -211,15 +211,15 @@ end allsubtypes_butAbsText(t) = setdiff(allsubtypes(AbsDocOrNode), [AbsText]) -@transform function addelm!(aml::Node, name::String, values::Vector, argAmlType::Type{allsubtypes_butAbsText(AbsDocOrNode)}) +@transform function addnode!(aml::Node, name::String, values::Vector, argAmlType::Type{allsubtypes_butAbsText(AbsDocOrNode)}) elms = Vector{Union{Node, Nothing}}(undef, length(values)) for (ielm, value) in enumerate(values) - elms[ielm] = addelm!(aml, name, value, argAmlType) + elms[ielm] = addnode!(aml, name, value, argAmlType) end return elms end -function addelm!(aml::Node, indicesstr::String, values::Vector, argAmlType::Type{AbsText}) +function addnode!(aml::Node, indicesstr::String, values::Vector, argAmlType::Type{AbsText}) indices = parse_textindices(indicesstr) if indices isa Colon indices = 1:length(elements(aml)) @@ -227,7 +227,7 @@ function addelm!(aml::Node, indicesstr::String, values::Vector, argAmlType::Type elms = Vector{Union{Node, Nothing}}(undef, length(indices)) ielm = 1 for (value, index) in zip(values, indices) - elms[ielm] = addelm!(aml, string(index), value, argAmlType) + elms[ielm] = addnode!(aml, string(index), value, argAmlType) ielm += 1 end return elms @@ -236,14 +236,14 @@ end ################################################################ # Dict -@transform function addelm!(aml::Node, name::String, values::AbstractDict, argAmlType::Type{allsubtypes(AbsDocOrNode)}) +@transform function addnode!(aml::Node, name::String, values::AbstractDict, argAmlType::Type{allsubtypes(AbsDocOrNode)}) # name is discarded now: actual names are stored in the Dict itself # elements are added directly # for AbsText, v_name is considered as the text index elms = Vector{Union{Node, Nothing}}(undef, length(values)) ielm = 1 for (v_name, v_value) in values - elms[ielm] = addelm!(aml, v_name, v_value, argAmlType) + elms[ielm] = addnode!(aml, v_name, v_value, argAmlType) ielm += 1 end end diff --git a/src/xmlutils/initializer.jl b/src/xmlutils/initializer.jl index 45bb5ba..7d46495 100644 --- a/src/xmlutils/initializer.jl +++ b/src/xmlutils/initializer.jl @@ -1,40 +1,40 @@ -export initialize_node +export createnode ################################################################ # Init ################################################################ # doc or element initialize """ - initialize_node(struct_nodetype) + createnode(struct_nodetype) Function to initialize the aml """ -function initialize_node(::Type{AbsHtml}, struct_name::String = "html") +function createnode(::Type{AbsHtml}, struct_name::String = "html") out = HTMLDocument() # no URI and external id htmlNode = ElementNode(struct_name) setroot!(out, htmlNode) # adding html node return out end -function initialize_node(::Type{AbsXml}, struct_name::String = "xml_root") +function createnode(::Type{AbsXml}, struct_name::String = "xml_root") out = XMLDocument() # version 1 xmlNode = ElementNode(struct_name) setroot!(out, xmlNode) # adding html node return out end -function initialize_node(::Type{<:AbsNormal}, struct_name::String) +function createnode(::Type{<:AbsNormal}, struct_name::String) out = ElementNode(struct_name) # element node return out end -function initialize_node(::Type{AbsText}, struct_name::String) +function createnode(::Type{AbsText}, struct_name::String) out = TextNode(struct_name) # text node return out end # no type method -function initialize_node(struct_name::String) +function createnode(struct_name::String) out = ElementNode(struct_name) # element node return out end diff --git a/src/xmlutils/updater.jl b/src/xmlutils/updater.jl index 66e5aa1..5834f54 100644 --- a/src/xmlutils/updater.jl +++ b/src/xmlutils/updater.jl @@ -80,8 +80,8 @@ function updatecontent!(value, name::String, node::Node, argAmlType::Type{<:Unio if !isnothing(elm) updatecontent!(value, elm, node, argAmlType) else - # addelm! if nothing is found - addelm!(node, name, value, argAmlType) + # addnode! if nothing is found + addnode!(node, name, value, argAmlType) end end @@ -90,8 +90,8 @@ function updatecontent!(value, name::String, node::Node, argAmlType::Type{<:AbsA if haskey(node, name) node[name] = value else - # addelm! if nothing is found - addelm!(node, name, value, argAmlType) + # addnode! if nothing is found + addnode!(node, name, value, argAmlType) end end @@ -104,8 +104,8 @@ function updatecontent!(values::Vector, name::String, node::Node, argAmlType::Ty if !isnothing(elms) updatecontent!(values, elms, node, argAmlType) else - # addelm! if nothing is found - addelm!(node, name, values, argAmlType) + # addnode! if nothing is found + addnode!(node, name, values, argAmlType) end end @@ -114,8 +114,8 @@ function updatecontent!(values::Vector, name::String, node::Node, argAmlType::Ty if haskey(node, name) node[name] .= values else - # addelm! if nothing is found - addelm!(node, name, values, argAmlType) + # addnode! if nothing is found + addnode!(node, name, values, argAmlType) end end diff --git a/test/xmlutils.jl b/test/xmlutils.jl index 3c3f29b..2f258cf 100644 --- a/test/xmlutils.jl +++ b/test/xmlutils.jl @@ -1,47 +1,47 @@ using AcuteML, Test @testset "xmlutils" begin - nsc = initialize_node(AbsEmpty, "some") + nsc = createnode(AbsEmpty, "some") @testset "Node" begin - n = initialize_node(AbsNormal, "a") + n = createnode(AbsNormal, "a") ################################################################ - addelm!(n, "normalString", "val", AbsNormal) + addnode!(n, "normalString", "val", AbsNormal) @test "val" == findcontent(String, "normalString", n, AbsNormal) @test ["val"] == findcontent("normalString", n, AbsNormal) updatecontent!("val2", "normalString", n, AbsNormal) @test "val2" == findcontent(String, "normalString", n, AbsNormal) - addelm!(n, "attString", "val", AbsAttribute) + addnode!(n, "attString", "val", AbsAttribute) @test "val" == findcontent(String, "attString", n, AbsAttribute) updatecontent!("val2", "attString", n, AbsAttribute) @test "val2" == findcontent(String, "attString", n, AbsAttribute) using Dates - addelm!(n, "Date", Date(2013,7,1), AbsNormal) + addnode!(n, "Date", Date(2013,7,1), AbsNormal) @test Date(2013,7,1) == findcontent(Date, "Date", n, AbsNormal) updatecontent!(Date(2013,7,2), "Date", n, AbsNormal) @test Date(2013,7,2) == findcontent(Date, "Date", n, AbsNormal) - addelm!(n, "Time", Time(12,53,40), AbsNormal) + addnode!(n, "Time", Time(12,53,40), AbsNormal) @test Time(12,53,40) == findcontent(Time, "Time", n, AbsNormal) updatecontent!(Time(12,53,41), "Time", n, AbsNormal) @test Time(12,53,41) == findcontent(Time, "Time", n, AbsNormal) - addelm!(n, "DateTime", DateTime(2013,5,1,12,53,40), AbsNormal) + addnode!(n, "DateTime", DateTime(2013,5,1,12,53,40), AbsNormal) @test DateTime(2013,5,1,12,53,40) == findcontent(DateTime, "DateTime", n, AbsNormal) updatecontent!( DateTime(2013,5,1,12,53,41), "DateTime", n, AbsNormal) @test DateTime(2013,5,1,12,53,41) == findcontent(DateTime, "DateTime", n, AbsNormal) using DataFrames - addelm!(n, "DataFrame", DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ), AbsNormal) + addnode!(n, "DataFrame", DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ), AbsNormal) @test_skip DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ) == findcontent(DataFrame, "DataFrame", n, AbsNormal) # updatecontent!( DataFrame(course = ["Artificial Intelligence", "Robotics2"], professor = ["Prof. A", "Prof. B"] ),"DataFrame", n, AbsNormal) # @test_skip DataFrame(course = ["Artificial Intelligence", "Robotics2"], professor = ["Prof. A", "Prof. B"] ) == findcontent(DataFrame, "DataFrame", n, AbsNormal) - addelm!(n, "Nothing", nothing, AbsAttribute) + addnode!(n, "Nothing", nothing, AbsAttribute) @test nothing == findcontent(Nothing, "Nothing", n, AbsAttribute) @test nothing == findcontent(Union{Nothing,String}, "Nothing", n, AbsAttribute) @@ -49,76 +49,76 @@ using AcuteML, Test # @test nothing == findcontent(Nothing, "Nothing", n, AbsAttribute) ################################################################ - addelm!(n, "stringVect", ["aa", "bb"], AbsNormal) + addnode!(n, "stringVect", ["aa", "bb"], AbsNormal) @test ["aa", "bb"] == findcontent(Vector{String}, "stringVect", n, AbsNormal) updatecontent!(["aa2", "bb"], "stringVect", n, AbsNormal) @test ["aa2", "bb"] == findcontent(Vector{String}, "stringVect", n, AbsNormal) - addelm!(n, "floatVect", [5.6, 7.8], AbsNormal) + addnode!(n, "floatVect", [5.6, 7.8], AbsNormal) @test [5.6, 7.8] == findcontent(Vector{Float64}, "floatVect", n, AbsNormal) updatecontent!([5.6, 7.9], "floatVect", n, AbsNormal) @test [5.6, 7.9] == findcontent(Vector{Float64}, "floatVect", n, AbsNormal) - addelm!(n, "intVect", [5, 6], AbsNormal) + addnode!(n, "intVect", [5, 6], AbsNormal) @test [5, 6] == findcontent(Vector{Int64}, "intVect", n, AbsNormal) updatecontent!([5, 7], "intVect", n, AbsNormal) @test [5, 7] == findcontent(Vector{Int64}, "intVect", n, AbsNormal) - addelm!(n, "DateVect", [Date(2013,7,1), Date(2014,7,1)], AbsNormal) + addnode!(n, "DateVect", [Date(2013,7,1), Date(2014,7,1)], AbsNormal) @test [Date(2013,7,1), Date(2014,7,1)] == findcontent(Vector{Date}, "DateVect", n, AbsNormal) updatecontent!([Date(2013,7,2), Date(2014,7,1)], "DateVect", n, AbsNormal) @test [Date(2013,7,2), Date(2014,7,1)] == findcontent(Vector{Date}, "DateVect", n, AbsNormal) - addelm!(n, "TimeVect", [Time(12,53,42), Time(12,53,40)], AbsNormal) + addnode!(n, "TimeVect", [Time(12,53,42), Time(12,53,40)], AbsNormal) @test [Time(12,53,42), Time(12,53,40)] == findcontent(Vector{Time}, "TimeVect", n, AbsNormal) updatecontent!([Time(12,53,43), Time(12,53,40)], "TimeVect", n, AbsNormal) @test [Time(12,53,43), Time(12,53,40)] == findcontent(Vector{Time}, "TimeVect", n, AbsNormal) - addelm!(n, "AnyVect", ["aa", Time(12,53,40), 2, nothing], AbsNormal) + addnode!(n, "AnyVect", ["aa", Time(12,53,40), 2, nothing], AbsNormal) @test string.(["aa", Time(12,53,40), 2]) == findcontent(typeof(["aa", Time(12,53,40), 2, nothing]), "AnyVect", n, AbsNormal) updatecontent!( ["aa", Time(12,53,40), 3, nothing], "AnyVect", n, AbsNormal) @test string.(["aa", Time(12,53,40), 3]) == findcontent(typeof(["aa", Time(12,53,40), 2, nothing]), "AnyVect", n, AbsNormal) end @testset "Html Document" begin - dhtml = initialize_node(AbsHtml, "html") + dhtml = createnode(AbsHtml, "html") - addelm!(dhtml, "normalString", "val", AbsNormal) + addnode!(dhtml, "normalString", "val", AbsNormal) @test "val" == findcontent(String, "normalString", dhtml, AbsNormal) @test ["val"] == findcontent("normalString", dhtml, AbsNormal) updatecontent!("val2", "normalString", dhtml, AbsNormal) @test "val2" == findcontent(String, "normalString", dhtml, AbsNormal) - addelm!(dhtml, "attString", "val", AbsAttribute) + addnode!(dhtml, "attString", "val", AbsAttribute) @test "val" == findcontent(String, "attString", dhtml, AbsAttribute) updatecontent!("val2", "attString", dhtml, AbsAttribute) @test "val2" == findcontent(String, "attString", dhtml, AbsAttribute) using Dates - addelm!(dhtml, "Date", Date(2013,7,1), AbsNormal) + addnode!(dhtml, "Date", Date(2013,7,1), AbsNormal) @test Date(2013,7,1) == findcontent(Date, "Date", dhtml, AbsNormal) updatecontent!(Date(2013,7,2), "Date", dhtml, AbsNormal) @test Date(2013,7,2) == findcontent(Date, "Date", dhtml, AbsNormal) - addelm!(dhtml, "Time", Time(12,53,40), AbsNormal) + addnode!(dhtml, "Time", Time(12,53,40), AbsNormal) @test Time(12,53,40) == findcontent(Time, "Time", dhtml, AbsNormal) updatecontent!(Time(12,53,41), "Time", dhtml, AbsNormal) @test Time(12,53,41) == findcontent(Time, "Time", dhtml, AbsNormal) - addelm!(dhtml, "DateTime", DateTime(2013,5,1,12,53,40), AbsNormal) + addnode!(dhtml, "DateTime", DateTime(2013,5,1,12,53,40), AbsNormal) @test DateTime(2013,5,1,12,53,40) == findcontent(DateTime, "DateTime", dhtml, AbsNormal) updatecontent!( DateTime(2013,5,1,12,53,41), "DateTime", dhtml, AbsNormal) @test DateTime(2013,5,1,12,53,41) == findcontent(DateTime, "DateTime", dhtml, AbsNormal) using DataFrames - addelm!(dhtml, "DataFrame", DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ), AbsNormal) + addnode!(dhtml, "DataFrame", DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ), AbsNormal) @test_skip DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ) == findcontent(DataFrame, "DataFrame", dhtml, AbsNormal) # updatecontent!( DataFrame(course = ["Artificial Intelligence", "Robotics2"], professor = ["Prof. A", "Prof. B"] ),"DataFrame", dhtml, AbsNormal) # @test_skip DataFrame(course = ["Artificial Intelligence", "Robotics2"], professor = ["Prof. A", "Prof. B"] ) == findcontent(DataFrame, "DataFrame", dhtml, AbsNormal) - addelm!(dhtml, "Nothing", nothing, AbsAttribute) + addnode!(dhtml, "Nothing", nothing, AbsAttribute) @test nothing == findcontent(Nothing, "Nothing", dhtml, AbsAttribute) @test nothing == findcontent(Union{Nothing,String}, "Nothing", dhtml, AbsAttribute) @@ -126,79 +126,79 @@ using AcuteML, Test # @test nothing == findcontent(Nothing, "Nothing", dhtml, AbsAttribute) ################################################################ - addelm!(dhtml, "stringVect", ["aa", "bb"], AbsNormal) + addnode!(dhtml, "stringVect", ["aa", "bb"], AbsNormal) @test ["aa", "bb"] == findcontent(Vector{String}, "stringVect", dhtml, AbsNormal) updatecontent!(["aa2", "bb"], "stringVect", dhtml, AbsNormal) @test ["aa2", "bb"] == findcontent(Vector{String}, "stringVect", dhtml, AbsNormal) - addelm!(dhtml, "floatVect", [5.6, 7.8], AbsNormal) + addnode!(dhtml, "floatVect", [5.6, 7.8], AbsNormal) @test [5.6, 7.8] == findcontent(Vector{Float64}, "floatVect", dhtml, AbsNormal) updatecontent!([5.6, 7.9], "floatVect", dhtml, AbsNormal) @test [5.6, 7.9] == findcontent(Vector{Float64}, "floatVect", dhtml, AbsNormal) - addelm!(dhtml, "intVect", [5, 6], AbsNormal) + addnode!(dhtml, "intVect", [5, 6], AbsNormal) @test [5, 6] == findcontent(Vector{Int64}, "intVect", dhtml, AbsNormal) updatecontent!([5, 7], "intVect", dhtml, AbsNormal) @test [5, 7] == findcontent(Vector{Int64}, "intVect", dhtml, AbsNormal) - addelm!(dhtml, "DateVect", [Date(2013,7,1), Date(2014,7,1)], AbsNormal) + addnode!(dhtml, "DateVect", [Date(2013,7,1), Date(2014,7,1)], AbsNormal) @test [Date(2013,7,1), Date(2014,7,1)] == findcontent(Vector{Date}, "DateVect", dhtml, AbsNormal) updatecontent!([Date(2013,7,2), Date(2014,7,1)], "DateVect", dhtml, AbsNormal) @test [Date(2013,7,2), Date(2014,7,1)] == findcontent(Vector{Date}, "DateVect", dhtml, AbsNormal) - addelm!(dhtml, "TimeVect", [Time(12,53,42), Time(12,53,40)], AbsNormal) + addnode!(dhtml, "TimeVect", [Time(12,53,42), Time(12,53,40)], AbsNormal) @test [Time(12,53,42), Time(12,53,40)] == findcontent(Vector{Time}, "TimeVect", dhtml, AbsNormal) updatecontent!([Time(12,53,43), Time(12,53,40)], "TimeVect", dhtml, AbsNormal) @test [Time(12,53,43), Time(12,53,40)] == findcontent(Vector{Time}, "TimeVect", dhtml, AbsNormal) - addelm!(dhtml, "AnyVect", ["aa", Time(12,53,40), 2, nothing], AbsNormal) + addnode!(dhtml, "AnyVect", ["aa", Time(12,53,40), 2, nothing], AbsNormal) @test string.(["aa", Time(12,53,40), 2]) == findcontent(typeof(["aa", Time(12,53,40), 2, nothing]), "AnyVect", dhtml, AbsNormal) updatecontent!( ["aa", Time(12,53,40), 3, nothing], "AnyVect", dhtml, AbsNormal) @test string.(["aa", Time(12,53,40), 3]) == findcontent(typeof(["aa", Time(12,53,40), 2, nothing]), "AnyVect", dhtml, AbsNormal) end @testset "XML Document" begin - dxml = initialize_node(AbsXml, "xml") + dxml = createnode(AbsXml, "xml") import EzXML: setroot! - setroot!(dxml, initialize_node(AbsNormal, "node")) + setroot!(dxml, createnode(AbsNormal, "node")) - addelm!(dxml, "normalString", "val", AbsNormal) + addnode!(dxml, "normalString", "val", AbsNormal) @test "val" == findcontent(String, "normalString", dxml, AbsNormal) @test ["val"] == findcontent("normalString", dxml, AbsNormal) updatecontent!("val2", "normalString", dxml, AbsNormal) @test "val2" == findcontent(String, "normalString", dxml, AbsNormal) - addelm!(dxml, "attString", "val", AbsAttribute) + addnode!(dxml, "attString", "val", AbsAttribute) @test "val" == findcontent(String, "attString", dxml, AbsAttribute) updatecontent!("val2", "attString", dxml, AbsAttribute) @test "val2" == findcontent(String, "attString", dxml, AbsAttribute) using Dates - addelm!(dxml, "Date", Date(2013,7,1), AbsNormal) + addnode!(dxml, "Date", Date(2013,7,1), AbsNormal) @test Date(2013,7,1) == findcontent(Date, "Date", dxml, AbsNormal) updatecontent!(Date(2013,7,2), "Date", dxml, AbsNormal) @test Date(2013,7,2) == findcontent(Date, "Date", dxml, AbsNormal) - addelm!(dxml, "Time", Time(12,53,40), AbsNormal) + addnode!(dxml, "Time", Time(12,53,40), AbsNormal) @test Time(12,53,40) == findcontent(Time, "Time", dxml, AbsNormal) updatecontent!(Time(12,53,41), "Time", dxml, AbsNormal) @test Time(12,53,41) == findcontent(Time, "Time", dxml, AbsNormal) - addelm!(dxml, "DateTime", DateTime(2013,5,1,12,53,40), AbsNormal) + addnode!(dxml, "DateTime", DateTime(2013,5,1,12,53,40), AbsNormal) @test DateTime(2013,5,1,12,53,40) == findcontent(DateTime, "DateTime", dxml, AbsNormal) updatecontent!( DateTime(2013,5,1,12,53,41), "DateTime", dxml, AbsNormal) @test DateTime(2013,5,1,12,53,41) == findcontent(DateTime, "DateTime", dxml, AbsNormal) using DataFrames - addelm!(dxml, "DataFrame", DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ), AbsNormal) + addnode!(dxml, "DataFrame", DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ), AbsNormal) @test_skip DataFrame(course = ["Artificial Intelligence", "Robotics"], professor = ["Prof. A", "Prof. B"] ) == findcontent(DataFrame, "DataFrame", dxml, AbsNormal) # updatecontent!( DataFrame(course = ["Artificial Intelligence", "Robotics2"], professor = ["Prof. A", "Prof. B"] ),"DataFrame", dxml, AbsNormal) # @test_skip DataFrame(course = ["Artificial Intelligence", "Robotics2"], professor = ["Prof. A", "Prof. B"] ) == findcontent(DataFrame, "DataFrame", dxml, AbsNormal) - addelm!(dxml, "Nothing", nothing, AbsAttribute) + addnode!(dxml, "Nothing", nothing, AbsAttribute) @test nothing == findcontent(Nothing, "Nothing", dxml, AbsAttribute) @test nothing == findcontent(Union{Nothing,String}, "Nothing", dxml, AbsAttribute) @@ -206,32 +206,32 @@ using AcuteML, Test # @test nothing == findcontent(Nothing, "Nothing", dxml, AbsAttribute) ################################################################ - addelm!(dxml, "stringVect", ["aa", "bb"], AbsNormal) + addnode!(dxml, "stringVect", ["aa", "bb"], AbsNormal) @test ["aa", "bb"] == findcontent(Vector{String}, "stringVect", dxml, AbsNormal) updatecontent!(["aa2", "bb"], "stringVect", dxml, AbsNormal) @test ["aa2", "bb"] == findcontent(Vector{String}, "stringVect", dxml, AbsNormal) - addelm!(dxml, "floatVect", [5.6, 7.8], AbsNormal) + addnode!(dxml, "floatVect", [5.6, 7.8], AbsNormal) @test [5.6, 7.8] == findcontent(Vector{Float64}, "floatVect", dxml, AbsNormal) updatecontent!([5.6, 7.9], "floatVect", dxml, AbsNormal) @test [5.6, 7.9] == findcontent(Vector{Float64}, "floatVect", dxml, AbsNormal) - addelm!(dxml, "intVect", [5, 6], AbsNormal) + addnode!(dxml, "intVect", [5, 6], AbsNormal) @test [5, 6] == findcontent(Vector{Int64}, "intVect", dxml, AbsNormal) updatecontent!([5, 7], "intVect", dxml, AbsNormal) @test [5, 7] == findcontent(Vector{Int64}, "intVect", dxml, AbsNormal) - addelm!(dxml, "DateVect", [Date(2013,7,1), Date(2014,7,1)], AbsNormal) + addnode!(dxml, "DateVect", [Date(2013,7,1), Date(2014,7,1)], AbsNormal) @test [Date(2013,7,1), Date(2014,7,1)] == findcontent(Vector{Date}, "DateVect", dxml, AbsNormal) updatecontent!([Date(2013,7,2), Date(2014,7,1)], "DateVect", dxml, AbsNormal) @test [Date(2013,7,2), Date(2014,7,1)] == findcontent(Vector{Date}, "DateVect", dxml, AbsNormal) - addelm!(dxml, "TimeVect", [Time(12,53,42), Time(12,53,40)], AbsNormal) + addnode!(dxml, "TimeVect", [Time(12,53,42), Time(12,53,40)], AbsNormal) @test [Time(12,53,42), Time(12,53,40)] == findcontent(Vector{Time}, "TimeVect", dxml, AbsNormal) updatecontent!([Time(12,53,43), Time(12,53,40)], "TimeVect", dxml, AbsNormal) @test [Time(12,53,43), Time(12,53,40)] == findcontent(Vector{Time}, "TimeVect", dxml, AbsNormal) - addelm!(dxml, "AnyVect", ["aa", Time(12,53,40), 2, nothing], AbsNormal) + addnode!(dxml, "AnyVect", ["aa", Time(12,53,40), 2, nothing], AbsNormal) @test string.(["aa", Time(12,53,40), 2]) == findcontent(typeof(["aa", Time(12,53,40), 2, nothing]), "AnyVect", dxml, AbsNormal) updatecontent!( ["aa", Time(12,53,40), 3, nothing], "AnyVect", dxml, AbsNormal) @test string.(["aa", Time(12,53,40), 3]) == findcontent(typeof(["aa", Time(12,53,40), 2, nothing]), "AnyVect", dxml, AbsNormal) From d80dcd29dd617f205e33573bbc5e64fe318b6375 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 07:54:24 -0500 Subject: [PATCH 12/13] deprecate addelm! and initialize_node --- src/xmlutils.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/xmlutils.jl b/src/xmlutils.jl index 4f94bbc..83e4030 100644 --- a/src/xmlutils.jl +++ b/src/xmlutils.jl @@ -26,3 +26,6 @@ include("xmlutils/findnode.jl") include("xmlutils/findcontent.jl") include("xmlutils/updater.jl") ################################################################ + +@deprecate addelm!(args...) addnode!(args...) +@deprecate initialize_node(args...) createnode(args...) From b5341d254c9a8e722c4ce8362b37bf8f9acec6ef Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 14 May 2020 12:58:26 +0000 Subject: [PATCH 13/13] Update precompile_*.jl file --- .../precompile/precompile_AcuteML.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deps/SnoopCompile/precompile/precompile_AcuteML.jl b/deps/SnoopCompile/precompile/precompile_AcuteML.jl index f25c33b..d334bbc 100644 --- a/deps/SnoopCompile/precompile/precompile_AcuteML.jl +++ b/deps/SnoopCompile/precompile/precompile_AcuteML.jl @@ -1,6 +1,5 @@ function _precompile_() ccall(:jl_generating_output, Cint, ()) == 1 || return nothing - isdefined(AcuteML, Symbol("#8#17")) && precompile(Tuple{getfield(AcuteML, Symbol("#8#17")),Nothing}) precompile(Tuple{Core.kwftype(typeof(AcuteML.render2file)),NamedTuple{(:id, :age, :field, :GPA, :courses),Tuple{Int64,Int64,String,Float64,Array{String,1}}},typeof(render2file),String,Bool}) precompile(Tuple{typeof(AcuteML.aml_create),Expr,Array{Union{Expr, Symbol},1},Array{Any,1},Array{Union{Expr, Symbol, Type},1},Array{Union{Expr, Symbol},1},Array{Union{Missing, String},1},Array{Union{Missing, Function, Symbol},1},Array{Union{Missing, Type},1},String,Type{T} where T,Array{Union{Missing, Function, Symbol},0},Bool,Array{Union{Nothing, Expr},1},Array{Union{Nothing, Expr},1},Array{Union{Nothing, Expr},1},Symbol}) precompile(Tuple{typeof(AcuteML.aml_parse),Expr}) @@ -11,17 +10,19 @@ function _precompile_() precompile(Tuple{typeof(AcuteML.multiString),Float64}) precompile(Tuple{typeof(AcuteML.multiString),Int64}) precompile(Tuple{typeof(AcuteML.multiString),String}) - precompile(Tuple{typeof(addnode!),Document,String,Nothing,Type{AbsAttribute}}) + precompile(Tuple{typeof(AcuteML.nodeparse),Type{T} where T,Node}) precompile(Tuple{typeof(addnode!),Node,String,Array{Any,1},Type{AbsNormal}}) precompile(Tuple{typeof(addnode!),Node,String,Array{Float64,1},Type{AbsNormal}}) precompile(Tuple{typeof(addnode!),Node,String,Array{Int64,1},Type{AbsNormal}}) precompile(Tuple{typeof(addnode!),Node,String,Array{String,1},Type{AbsNormal}}) - precompile(Tuple{typeof(addnode!),Node,String,Float64,Type{AbsNormal}}) - precompile(Tuple{typeof(addnode!),Node,String,Int64,Type{AbsNormal}}) precompile(Tuple{typeof(addnode!),Node,String,Nothing,Type{AbsAttribute}}) precompile(Tuple{typeof(addnode!),Node,String,Nothing,Type{AbsNormal}}) precompile(Tuple{typeof(addnode!),Node,String,String,Type{AbsAttribute}}) precompile(Tuple{typeof(addnode!),Node,String,String,Type{AbsNormal}}) + precompile(Tuple{typeof(createnode),Type{AbsEmpty},String}) + precompile(Tuple{typeof(createnode),Type{AbsHtml},String}) + precompile(Tuple{typeof(createnode),Type{AbsNormal},String}) + precompile(Tuple{typeof(createnode),Type{AbsXml},String}) precompile(Tuple{typeof(findcontent),String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),Type{Array{Any,1}},String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),Type{Array{Float64,1}},String,Node,Type{AbsNormal}}) @@ -31,14 +32,13 @@ function _precompile_() precompile(Tuple{typeof(findcontent),Type{String},String,Node,Type{AbsAttribute}}) precompile(Tuple{typeof(findcontent),Type{String},String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(findcontent),Type{Union{Nothing, String}},String,Node,Type{AbsAttribute}}) - precompile(Tuple{typeof(createnode),Type{AbsEmpty},String}) - precompile(Tuple{typeof(createnode),Type{AbsHtml},String}) - precompile(Tuple{typeof(createnode),Type{AbsNormal},String}) - precompile(Tuple{typeof(createnode),Type{AbsXml},String}) precompile(Tuple{typeof(newTemplate),String,Symbol}) precompile(Tuple{typeof(newTemplate),String}) + precompile(Tuple{typeof(updatecontent!),Array{Any,1},Array{Node,1},Node,Type{T} where T}) precompile(Tuple{typeof(updatecontent!),Array{Any,1},String,Node,Type{AbsNormal}}) + precompile(Tuple{typeof(updatecontent!),Array{Float64,1},Array{Node,1},Node,Type{T} where T}) precompile(Tuple{typeof(updatecontent!),Array{Float64,1},String,Node,Type{AbsNormal}}) + precompile(Tuple{typeof(updatecontent!),Array{Int64,1},Array{Node,1},Node,Type{T} where T}) precompile(Tuple{typeof(updatecontent!),Array{Int64,1},String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(updatecontent!),Array{String,1},String,Node,Type{AbsNormal}}) precompile(Tuple{typeof(updatecontent!),String,String,Node,Type{AbsAttribute}})