473,379 Members | 1,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

XSLT - Turns <br/> into <br> ?

4
I'm new to XSLT, it what our old website developer used but he has now left our company. I have been given the task of making our site output as valid XHTML as I can get it. Currently in the .XSL files I write self-closing tags like <br/> but in the output XHTML they come out as <br> and therefore the page doesn't validate. This happens for other self-closing tags like <img src=""/> too.

I don't really know XSLT so I don't know how I can fix this from happening. Any suggestions?!
Jul 23 '07 #1
6 2378
jkmyoung
2,057 Expert 2GB
What xslt processor or process are you using?
Do you have an
<xsl:output> tag at the beginning, and if so, are you setting type="html" as opposed to "xml" or "xhtml"?
Jul 23 '07 #2
JoeS
4
Perfect - I changed it to 'xhtml' and it now outputs self-closing tags. Thanks you :)

One slight problem that's occuring now though - in the XSL there are these lines:

Expand|Select|Wrap|Line Numbers
  1. <!-- start the stylesheet -->
  2. <xsl:template match="/">
  3.     <xsl:apply-templates select="XML"/>
  4. </xsl:template>
  5.  
  6. <!-- xml tempate -->
  7. <xsl:template match="XML">
  8.  
  9. <p>test</p>
  10.  


This is now causing this line to appear in my XHTML:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <p>test<p/>
  3.  
I'm sure this shouldn't be there?
Jul 24 '07 #3
jkmyoung
2,057 Expert 2GB
If you don't want it in there, then remove those lines. Or are you talking about the xml type declaration?
Jul 24 '07 #4
JoeS
4
yes this part shouldn't be output in the xhtml should it? i thought you only need this at the top of xml documents not xhtml webpages?
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
Jul 25 '07 #5
jkmyoung
2,057 Expert 2GB
Ok, just add the attribute omit-xml-declaration="no" to the xsl:output node.
Jul 25 '07 #6
JoeS
4
That didn't work, but "omit-xml-declaration="yes"" did :) Thanks ever so much for your help!
Jul 25 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Son KwonNam | last post by:
I'm working with XSLT for changing XML to XSLT. for example, I have the follower xml data --------- <article writer="you"> <contents><!]></contents> --------- then I want to get the...
9
by: loveNUNO | last post by:
I'am using xt to convert my xml with an xsl to html. When i use <br /> in my xsl document in turns into <br> in the html. So, How am I get <br/> TAG in output(html) like xhtml?
4
by: fis | last post by:
Hi all, I've problem because there are needed break lines in my texts on the web site but i can't do it :( My pipeline looks like: XMS -> I18N -> XSLT -> HTML I have lot of texts in my...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
7
by: noor.rahman | last post by:
I have an XML file that stores data from an HTML form. I use XSL to display the data in HTML format. The data may have newline characters. However, XSL is not displaying the newlines properly in...
2
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
1
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
9
by: Wayne | last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test $p = str_replace ("%0D%0A", "<br>", $a); That is the above code that I am using, however, it is not picking up the CR/LF from the textarea. I...
7
by: Nathan Sokalski | last post by:
Something that I recently noticed in IE6 (I don't know whether it is true for other browsers or versions of IE) is that it renders <br/and <br></br> differently. With the <br/version, which is what...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.