Jump to content
groads2

xls transform to html and have all the spaces as   so browser can display correctly.

Recommended Posts

I have this blob of text in on of the xml strings that I am receiving and transforming to html with xsl 1.0. I need to display it with all the white space preserved in a chromium object. I have read as much as someone can read on the subject of using xsl to transform this to html with the whitespace and tried a lot of those suggestions without getting the html to display correctly in the browser window. I have attached the xml. Anyone have a solution? Thanks.

Edited by groads2

Share this post


Link to post
Share on other sites

Well HTML has the "pre" element so write a template that transforms the MessageResponse element into a "pre" element:

<xsl:template match="ns5:MessageResponse">  <pre><xsl:value-of select="."/></pre></xsl:template>

of course making sure the stylesheet declares

xmlns:ns5="https://enroute.com/ctsp/queries/1.0"

on the xsl: stylesheet element.Then all you need is to make sure the template is used, the built-in templates should ensure that, if you write your own make sure you use apply-templates e.g.

<xsl:template match="/">  <html>	 <head>	    <title>Example</title>    </head>    <body>	   <xsl:apply-templates/>    </body>  </html></xsl:template>

Share this post


Link to post
Share on other sites

Well my suggestion is not to try to convert line breaks to "br" elements but instead simply put the text with the line breaks into a HTML "pre" element as then the browser will render line breaks as line breaks and will not collapse white space as it happens in other elements like the "p" element.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...