#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    16
    Rep Power
    0

    My xsl template will not write out <br/> to html.


    I am trying to generate html to display this xml. Why can't the called template output the <br/>

    xml Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
    				xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    				xmlns:ns1="http://niem.gov/niem/appinfo/2.0"
    				xmlns:ns2="http://niem.gov/niem/structures/2.0"
    				xmlns:ns3="https://collect.prodcjis.ct.gov/ctsp/ext/1.0"
    				xmlns:ns4="https://collect.prodcjis.ct.gov/ctsp/ncic/1.0"
    				xmlns:ns5="https://collect.prodcjis.ct.gov/ctsp/queries/1.0"
    				xmlns:ns6="https://collect.prodcjis.ct.gov/ctsp/messages/1.0"
    				xmlns:ns7="https://collect.prodcjis.ct.gov/ctsp/NLETS/1.0">
     
    	<!-- xsl<img src="http://images.devshed.com/fds/smilies/tongue.gif" border="0" alt="" title="Stick Out Tongue" class="inlineimg" />reserve-space elements="ns5:MessageResponse"/ -->
    	<xsl<img src="http://images.devshed.com/fds/smilies/redface.gif" border="0" alt="" title="Embarrassment" class="inlineimg" />utput method="html"/>
    	<xsl:template match="ns5:CorrelatedMessageResponse">
    		<html>
    			<head>
    				<style>
    					.corrTextReply{font-family:"Courier New"}
    				</style>
    			</head>
    			<body class="corrTextReply">
    				<br/>
    				Why does the break get written here but not in the other templates
    				<br/>
    				<xsl:variable name="tmp1">
    					<xsl:call-template name="add-br">
    						<xsl:with-param name="text" select="//ns5:MessageResponse"/>
    					</xsl:call-template>
    				</xsl:variable>
    				<xsl:variable name="tmp2">
    					<xsl:call-template name="string-replace-all">
    						<xsl:with-param name="text" select="$tmp1" />
    						<xsl:with-param name="replace" select="' '" />
    						<xsl:with-param name="by" select="'SPACE'" />
    					</xsl:call-template>
    				</xsl:variable>
    				<xsl:value-of select="$tmp2"/>
    			</body>
    		</html>
    	</xsl:template>
     
    	<xsl:template name="string-replace-all">
    		<xsl<img src="http://images.devshed.com/fds/smilies/tongue.gif" border="0" alt="" title="Stick Out Tongue" class="inlineimg" />aram name="text" />
    		<xsl<img src="http://images.devshed.com/fds/smilies/tongue.gif" border="0" alt="" title="Stick Out Tongue" class="inlineimg" />aram name="replace" />
    		<xsl<img src="http://images.devshed.com/fds/smilies/tongue.gif" border="0" alt="" title="Stick Out Tongue" class="inlineimg" />aram name="by" />
    		<xsl:choose>
    			<xsl:when test="contains($text, $replace)">
    				<xsl:value-of select="substring-before($text,$replace)" />
    				<xsl:choose>
    					<xsl:when test="$by='SPACE'">
    						<xsl:text>*</xsl:text>
    					</xsl:when>
    				</xsl:choose>
    				<xsl:call-template name="string-replace-all">
    					<xsl:with-param name="text" select="substring-after($text,$replace)" />
    					<xsl:with-param name="replace" select="$replace" />
    					<xsl:with-param name="by" select="$by" />
    				</xsl:call-template>
    			</xsl:when>
    			<xsl<img src="http://images.devshed.com/fds/smilies/redface.gif" border="0" alt="" title="Embarrassment" class="inlineimg" />therwise>
    				<xsl:value-of select="$text" />
    			</xsl<img src="http://images.devshed.com/fds/smilies/redface.gif" border="0" alt="" title="Embarrassment" class="inlineimg" />therwise>
    		</xsl:choose>
    	</xsl:template>
     
    	<xsl:template name="add-br">
    		<xsl<img src="http://images.devshed.com/fds/smilies/tongue.gif" border="0" alt="" title="Stick Out Tongue" class="inlineimg" />aram name="text" select="."/>
    		<xsl:choose>
    			<xsl:when test="contains($text, '&amp;#xD;')">
    				<xsl:value-of select="substring-before($text, '&amp;#xD;')"/>
    				<br/>
    				<xsl:call-template name="add-br">
    					<xsl:with-param name="text" select="substring-after($text,'&amp;#xD;')"/>
    				</xsl:call-template>
    			</xsl:when>
    			<xsl<img src="http://images.devshed.com/fds/smilies/redface.gif" border="0" alt="" title="Embarrassment" class="inlineimg" />therwise>
    				<xsl:value-of select="$text"/>
    			</xsl<img src="http://images.devshed.com/fds/smilies/redface.gif" border="0" alt="" title="Embarrassment" class="inlineimg" />therwise>
    		</xsl:choose>
    	</xsl:template>
    </xsl:stylesheet>


    my xml is:
    Code:
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body><ns5:CorrelatedMessageResponse xmlns:ns1="http://niem.gov/niem/appinfo/2.0" xmlns:ns2="http://niem.gov/niem/structures/2.0" xmlns:ns3="https://collect.prodcjis.ct.gov/ctsp/ext/1.0" xmlns:ns4="https://collect.prodcjis.ct.gov/ctsp/ncic/1.0" xmlns:ns5="https://collect.prodcjis.ct.gov/ctsp/queries/1.0" xmlns:ns6="https://collect.prodcjis.ct.gov/ctsp/messages/1.0" xmlns:ns7="https://collect.prodcjis.ct.gov/ctsp/NLETS/1.0"><ns3:ResponseFormat>TEXT</ns3:ResponseFormat><ns5:MessageResponse>[redacted text data]</ns5:MessageResponse></ns5:CorrelatedMessageResponse></soapenv:Body></soapenv:Envelope>
    Last edited by requinix; January 2nd, 2014 at 04:22 PM. Reason: code tags (2013-05-13); xml redacted at poster's request (2014-01-01)
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    16
    Rep Power
    0
    I found a solution to the problem online. I wish I could remember where so I could give them credit. The one line needed to be changed to a copy-of instead of a value-of when returning the final result of the transformation since the data now has tags in the result that I wanted.

    Code:
    <xsl:copy-of select="$tmp2"/>

IMN logo majestic logo threadwatch logo seochat tools logo