I have the following XML. I want to convert this using a XSL-FO to add a line break where there is <escape V=".br"/>
and to bold the text between <escape V="H"/>
and <escape V="N"/>
. Any suggestions? Even a XML->html example would suffice.
<OBX.5>
Tan<escape V=".br"/>MB BS FRACS PhD<escape
V=".br"/>Hospital & Specialist Centre<escape
V=".br"/>Address:<escape
V=".br"/>XX XX Street<escape
V=".br"/>XXX<escape
V=".br"/>HUTT 5011<escape
V=".br"/>Date of Birth:<escape
V=".br"/>15.03.1987<escape
V=".br"/>Telephone:<escape
V=".br"/>(h) 9888 26846<escape
V=".br"/>(m) 0221 632 4590<escape
V=".br"/>HI Number:<escape
V=".br"/>JAP5065<escape V=".br"/>
<escape V=".br"/>
After the 5 dots is a Bolded Line.....<escape
V="H"/> TEST Escape Characters<escape V="N"/>TEST more
<escape V=".br"/>
</OBX.5>
This would work, but explicitly not for nested formatting (i.e. bold + italic):
Output for your sample:
Note that only
escape[@V = '.br']
actually create a line break, so "After the 5 dots is a Bolded Line....." cannot be true for your input.The XPath expressions I use take some explaining, so here it is.
Imagine the children of
<OBX.5>
as this list:where
H
iscount(preceding-sibling::escape[@V = 'H'])
N
iscount(preceding-sibling::escape[@V = 'N'])
H-N
is the difference of the two, obviously.So with
we work on all nodes except
#32
and#33
.Template #3 gives special treatment to
#31
, rendering a bold container which contains:where the XPath translates to
escape[@V = 'N']
preceding-sibling
) and select all nodes whereescape[@V = 'H']
is the same ID as the currentescape[@V = 'H']
.This condition only applies to
#32
and#33
in your example, effectively it slices the list of nodes in a way that prevents rendering more text as bold than required.Node
#33
is discarded by template #4, we only need it for counting purposes.