Using <br /> tag within XML for XLST

karmin

New Member
I am currently running into some trouble with an XML/XLST to HTML conversion I am working on. In short, I want to use \[code\]<br />\[/code\] tags within an XML tag, so that the HTML file after transformation will display a line break. After some tries I got that to work, however at the cost of some other functionallity. Namely the abillity to highlight parts.First the dumped down XML file. So basically, there are several possible tags which all contain a first and last name. In this case I want the first and last name to be parsed on a seperate line (hence the \[code\]<br />\[/code\] tag). Furthermore in some instances a first or last name will need to be highlighted. In this case on line 3, last name "The Hand".\[code\]<swift_native><tag tag_code=":1:"><![CDATA[Jaco<br />Ronnie]]></tag><tag tag_code=":2:"><![CDATA[John<br />Doe]]></tag><tag tag_code=":2:"><![CDATA[Robbie<br />]]><highlight>The Hand</highlight></tag></swift_native>\[/code\]So far, depending on the method I use within the XLST I either am able to get the linebreaks correct or the highlighting. But not both: The following figure shows this.
LeMXWxq.png
Below you see the used XLST file. Where you can see that using \[code\]<xsl:apply-templates/>\[/code\] will make the highlighting work and \[code\]<xsl:value-of select="." disable-output-escaping="yes"/>\[/code\] will let me use the \[code\]<br />\[/code\] correctly.\[code\]<?xml version="1.0"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><!-- HTML Layout definition --><xsl:output method="html"/><xsl:template match="swift_native"> <html> <head> <title> <xsl:apply-templates select="message_id"/> </title> <style type="text/css"> #tbl1,#tbl2 {display:none;} #lnk1,#lnk2 {border:none;background:none;width:85px;} td {FONT-SIZE: 75%; MARGIN: 0px; COLOR: #000000;} td {FONT-FAMILY: verdana,helvetica,arial,sans-serif} a {TEXT-DECORATION: none;} table.subtable {border-collapse:collapse;} table.subtable td {border:1px solid black;} </style> </head> <body> <table cellpadding="3" width="100%" class="subtable"> <tr bgcolor="#cccccc"> <td colspan="3">Block4</td> </tr> <xsl:apply-templates select="tag" /> </table> </body> </html></xsl:template><!-- Variable definition --><xsl:template match="tag"> <tr> <td> <b> <xsl:value-of select="@tag_code" /> </b> </td> <td> <xsl:value-of select="." disable-output-escaping="yes"/> </td> <td> <xsl:apply-templates/> </td> </tr></xsl:template><xsl:template match="highlight"> <span style="background-color:yellow;"> <xsl:apply-templates/> </span></xsl:template></xsl:stylesheet>\[/code\]Obviously, the question is: does someone know a way in which I can use both the \[code\]<br />\[/code\] tag as the highlighting?
 
Back
Top