In the XML file cross-links are not expended like 2–5 and final latex should be \citep{B2,B3,B4,B5}.
Any Number should expend in all the cross-links like, if XML coded as 11–18 it should be convert to \citep{B11,B12,B13,B14,B15,B16,B17,B18} (beginning to end). How to get the expected result using LuaLaTeX?
My XML is:
\documentclass{article}
\usepackage{luacode}
\begin{document}
\begin{luacode}
local domobject = require "luaxml-domobject"
local transform = require "luaxml-transform"
sample = [[
<?xml version="1.0" encoding="utf-8"?>
<art>
<title>Scattering of flexural waves an electric current</title>
<para>Smart testing structures are $a+b$ components Reduce acoustic noise used in engineering applications that are capable of sensing or reacting to their environment change <?LuaLaTeX Sample XXX1?> their mechanical properties. in a predictable and desired manner. In addition to carrying mechanical loads, <?LuaLaTeX \hspace{12pt}Abc?> alleviate vibration, reduce acoustic noise, change their mechanical properties as required or monitor their own condition.</para>
<para>The first <xref ref-type="section" rid="Sec1">Section 1</xref> description and correlation between gait impairment and hydrocephalus were made in 1965 by Hakim and Adam (<xref ref-type="bibr" rid="B1">1</xref>). The etiology of idiopathic normal pressure hydrocephalus (iNPH) has not yet been entirely understood (<xref ref-type="bibr" rid="B2">2</xref>–<xref ref-type="bibr" rid="B5">5</xref>). In elderly patients, other conditions such as spinal canal stenosis, Parkinson's disease, and polyneuropathy may influence the gait negatively.</para>
</art>]]
local dom = domobject.parse(sample)
local function process_instructions(el)
for _, child in ipairs(el:get_children()) do
local ntype = child:get_node_type()
if ntype == "PI" and child._name=="LuaLaTeX" then
local text = child._attr[ "_text" ]
local newel = el:create_element("lualatex-instruction", {text = text})
child:replace_node(newel)
end
if child:is_element() then
process_instructions(child)
end
end
end
process_instructions(dom:root_node())
local transformer = transform.new()
transformer:add_action("title", "\section{@<.>}")
transformer:add_action("para", "@<.>\par")
-- handle the processing instruction
transformer:add_custom_action("lualatex-instruction",
function(el)
return el:get_attribute("text")
end)
transform.print_tex(transformer:process_dom(dom))
\end{luacode*}
\end{document}
I have expected output LaTeX file is:
Smart testing structures are $a+b$ components Reduce acoustic noise used in
engineering applications that are capable of sensing or reacting to their environment change Sample XXX1 their mechanical properties. in a predictable
and desired manner. In addition to carrying mechanical loads,
Abc alleviate
vibration, reduce acoustic noise, change their mechanical properties as required
or monitor their own condition.
The first Section 1 description and correlation between gait impairment and
hydrocephalus were made in 1965 by Hakim and Adam (\citep{B1}). The etiology of idio-
pathic normal pressure hydrocephalus (iNPH) has not yet been entirely under-
stood (\citep{B2,B3,B4,B5}). In elderly patients, other conditions such as spinal canal stenosis,
Parkinson’s disease, and polyneuropathy may influence the gait negatively.
sampleand never use it, so this document has no output. – David Carlisle Jul 19 '23 at 16:26xref. But not any idea expand the attribute values (like B2,B3,B4,B5).. How to get this? – Balaji Jul 20 '23 at 11:27