XML utilities

Helpers for reading and resolving XML parameter targets.

ModelManager.createXMLFileMethod
createXMLFile(location::Symbol, M::AbstractMonad)

Create (if needed) the variation XML file for location in monad M and return its path.

The file is written to <location_folder>/<variations_subfolder>/<location>_variation_<id>.xml. If the file already exists it is returned immediately. After writing, calls postVariationXMLProcessing to allow simulator-specific post-processing.

source
ModelManager.elementIsTerminalMethod
elementIsTerminal(e::XMLElement)

Check if an XML element is terminal (i.e., has no child elements). Returns true if the element has no children, false otherwise.

source
ModelManager.getChildByAttributeMethod
getChildByAttribute(parent_element::XMLElement, path_element_split::Vector{<:AbstractString})

Get the child element of parent_element that matches the given tag and attribute.

source
ModelManager.getChildByChildContentMethod
getChildByChildContent(current_element::XMLElement, path_element::AbstractString)

Get the child element of current_element that matches the given tag and child content.

source
ModelManager.getSimpleContentMethod
getSimpleContent(xml_doc::XMLDocument, xml_path::Vector{<:AbstractString}; required::Bool=true)

Get the content of the element in the XML document that matches the given path. See retrieveElement.

Validates that the element is terminal (has no child elements) and contains non-empty text content. Throws AssertionError if either condition is not met.

source
ModelManager.postVariationXMLProcessingMethod
postVariationXMLProcessing(location::Symbol, path_to_xml::String)
postVariationXMLProcessing(::AbstractSimulator, location::Symbol, path_to_xml::String)

Hook called immediately after createXMLFile writes a variation XML file at path_to_xml for location. Default is a no-op.

Simulator packages may override postVariationXMLProcessing(::TheirSimulator, location, path) for location-specific post-processing (e.g. splitting out embedded SBML files).

source
ModelManager.prepareBaseFileMethod
prepareBaseFile(input_folder::InputFolder)
prepareBaseFile(::AbstractSimulator, input_folder::InputFolder)

Return the path to the base input file for input_folder, or nothing if the folder has no base file.

Default implementation: joinpath(locationPath(input_folder), input_folder.basename), or nothing if input_folder.basename is missing.

Simulator packages may override prepareBaseFile(::TheirSimulator, input_folder) for location types that require special handling (e.g. generating a base file on demand).

source
ModelManager.retrieveElementMethod
retrieveElement(xml_doc::XMLDocument, xml_path::Vector{<:AbstractString}; required::Bool=true)

Retrieve the element in the XML document that matches the given path.

If required is true, an error is thrown if the element is not found. Otherwise, nothing is returned if the element is not found.

source
ModelManager.retrieveElementErrorMethod
retrieveElementError(xml_path::Vector{<:AbstractString}, path_element::String)

Throw an error if the element defined by xml_path is not found in the XML document, including the path element that caused the error.

source
ModelManager.setSimpleContentMethod
setSimpleContent(xml_doc::XMLDocument, xml_path::Vector{<:AbstractString}, new_value::Union{Int,Real,String})

Update the content of the element in the XML document that matches the given path with the new value. See retrieveElement.

Validates that the element is terminal (has no child elements) before setting content. Throws AssertionError if the element has child elements.

source