473,715 Members | 5,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xsl with <br/> problem

Hi,

I am having a small problem, that is driving me nuts.
My application reads some Xml and runs 2 Xsl Transformations to generate
HTML. As soon as my second XSL introduces some <br/tags, the application
crashes with the same error message I would get when writing <brand no
closing tag. To make everything a little stranger, even <br></brseems to
be bad while <lbr/is fine. Ive tried some other tag names and the problem
only appears with br-tags ... any ideas?

Regards,
Chris

Jan 2 '07 #1
4 4340
You forgot to provide your code

Cheers,
Dimitre Novatchev
"Christofer Dutz" <ch************ *@univativ.dewr ote in message
news:00******** **********@fe62 .usenetserver.c om...
Hi,

I am having a small problem, that is driving me nuts.
My application reads some Xml and runs 2 Xsl Transformations to generate
HTML. As soon as my second XSL introduces some <br/tags, the application
crashes with the same error message I would get when writing <brand no
closing tag. To make everything a little stranger, even <br></brseems to
be bad while <lbr/is fine. Ive tried some other tag names and the
problem only appears with br-tags ... any ideas?

Regards,
Chris


Jan 2 '07 #2
Oh gee ... I thought this might be a stadard issue and I didn't need to.
Here is my Transformer Component:

using System;
using System.Data;
using System.Collecti ons;
using System.Configur ation;
using System.IO;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using System.Xml.XPat h;
using System.Xml.Xsl;

/// <summary>
/// Zusammenfassung sbeschreibung für Class1
/// </summary>
namespace Transformers
{
public class XslTransformer : AbstractTransfo rmer
{
protected XslCompiledTran sform myXslTrans;

public XslTransformer( )
{
}

override public void Setup(HttpReque st request, HttpResponse
response, SortedList parameters)
{
String templateUri = (String) parameters["src"];

// Setup a cleanup transformation, since the sql server sends us
really crap code
myXslTrans = new XslCompiledTran sform();
myXslTrans.Load (templateUri);
}

override public void Destroy()
{
myXslTrans = null;
}

public override XPathDocument Produce()
{
XPathDocument inputDoc = this.producer.P roduce();

// Write the result to an in-memory temorary document
MemoryStream memStream = new MemoryStream();

// Execute the transformation
myXslTrans.Tran sform(inputDoc, null, memStream);

// Reset the memory stream so the "read-head" points to
// the beginning of the document
memStream.Posit ion = 0;
// Create a new Dom Object from the byte junk in the memStream
XPathDocument outputDoc = new XPathDocument(m emStream);
return outputDoc;
}
}
}

And here the Xsl, but I don't really understand why "<br/>" doesn't work and
"<lbr/>" does. No matter where I have a <br/tag ... execution fails when
creating the new XPathDocument outputDoc:

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

<xsl:template match="/profil">

<html>

<body>

<h1>Mitarbeit er-Profil</h1>

<table>

<tr>

<td>

<image src="http://192.168.1.102/Univativ/MA_Fotos/MA_{person/id}.jpg"
height="100"/>

</td>

<td>

<h2>

<xsl:if test="person/akademischer-titel">

<xsl:value-of select="person/akademischer-titel"/>

<xsl:text disable-output-escaping="yes"</xsl:text>

</xsl:if>

<xsl:value-of select="person/vorname"/>

<xsl:text disable-output-escaping="yes"</xsl:text>

<xsl:value-of select="person/nachname"/>

</h2>geboren am : <xsl:value-of select="person/geburtstag"/>

</td>

</tr>

<xsl:if test="/profil/ausbildung/studium">

<tr>

<td>

<h3>Studium</h3>

</td>

<td>

<xsl:for-each select="/profil/ausbildung/studium/studiengaenge/studiengang">

<b><xsl:choos e>

<xsl:when test="(string-length(@von) = 0) and (string-length(@bis) = 0)"/>

<xsl:when test="(string-length(@von) = 0)">bis <xsl:value-of
select="@bis"/>: </xsl:when>

<xsl:when test="(string-length(@bis) = 0)">seit <xsl:value-of
select="@von"/>: </xsl:when>

<xsl:otherwise> <xsl:value-of select="@von"/- <xsl:value-of
select="@bis"/>: </xsl:otherwise>

</xsl:choose><xsl :value-of select="@bezeih nung"/>, <xsl:value-of
select="@univer sitaet"/>

</b><xsl:value-of select="@abschl uss"/>

</xsl:for-each>

</td>

</tr>

</xsl:if>

<xsl:if test="/profil/ausbildung/lehre">

<tr>

<td>

<h3>Ausbildunge n</h3>

</td>

<td>

<b>Ausbildungen </b>

</td>

</tr>

</xsl:if>

<xsl:if test="/profil/praxiserfahrung/projekt">

<tr>

<td>

<h3>Praxisrefer enzen</h3>

</td>

<td>

<xsl:for-each select="/profil/praxiserfahrung/projekt">

<b>

<xsl:choose>

<xsl:when test="(string-length(@von) &gt; 0) and (string-length(@bis) &gt;
0)">

<xsl:value-of select="@von"/- <xsl:value-of select="@bis"/>

</xsl:when>

<xsl:when test="(string-length(@von) &gt; 0)">

seit <xsl:value-of select="@von"/>

</xsl:when>

<xsl:when test="(string-length(@bis) &gt; 0)">

bis <xsl:value-of select="@bis"/>

</xsl:when>

</xsl:choose>:<xs l:value-of select="@firma"/>, <xsl:value-of select="@ort"/>

</b>

<br/>

<xsl:value-of select="@titel"/>

<xsl:if test="position( ) != last()">

<br/>

<lbr/>

<lbr/>

</xsl:if>

</xsl:for-each>

</td>

</tr>

</xsl:if>

<tr>

<td>

<h3>Kenntniss e</h3>

</td>

<td>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Hardware']">

<b>Hardware</b>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Hardware' and @auspraegung = 3]">

sehr gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Hardware' and @auspraegung = 3]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Hardware' and @auspraegung = 2]">

gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Hardware' and @auspraegung = 2]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Hardware' and @auspraegung = 1]">

Grundlagen: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Hardware' and @auspraegung = 1]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Betriebssystem e']">

<b>Betriebssyst eme</b>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Betriebssystem e' and @auspraegung = 3]">

sehr gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Betriebssystem e' and @auspraegung = 3]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Betriebssystem e' and @auspraegung = 2]">

gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Betriebssystem e' and @auspraegung = 2]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Betriebssystem e' and @auspraegung = 1]">

Grundlagen: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Betriebssystem e' and @auspraegung = 1]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Office-Anwendungen']">

<b>Office-Anwendungen</b>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Office-Anwendungen' and @auspraegung = 3]">

sehr gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Office-Anwendungen' and @auspraegung = 3]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Office-Anwendungen' and @auspraegung = 2]">

gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Office-Anwendungen' and @auspraegung = 2]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Office-Anwendungen' and @auspraegung = 1]">

Grundlagen: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Office-Anwendungen' and @auspraegung = 1]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Datenbanken']">

<b>Datenbanke n</b>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Datenbanken' and @auspraegung = 3]">

sehr gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Datenbanken' and @auspraegung = 3]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Datenbanken' and @auspraegung = 2]">

gut: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Datenbanken' and @auspraegung = 2]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<xsl:if test="/profil/faehigkeiten/faehigkeit[@bereich = 'EDV-Kenntnisse'
and @gruppe = 'Datenbanken' and @auspraegung = 1]">

Grundlagen: <xsl:for-each select="/profil/faehigkeiten/faehigkeit[@bereich =
'EDV-Kenntnisse' and @gruppe = 'Datenbanken' and @auspraegung = 1]">

<xsl:value-of select="@bezeic hnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<lbr/>

</xsl:if>

</td>

</tr>

<xsl:if test="/profil/person/sprachen/sprache">

<tr>

<td>

<h3>Sprachen</h3>

</td>

<td>

<xsl:for-each select="/profil/person/sprachen/sprache">

<xsl:value-of select="@bezeic hnung"/><!-- - <xsl:choose>

<xsl:when test="@sprachbe herschungs-grad = '1'">schlecht</xsl:when>

<xsl:when test="@sprachbe herschungs-grad = '2'">gut</xsl:when>

<xsl:when test="@sprachbe herschungs-grad = '3'">sehr gut</xsl:when>

</xsl:choose>-->

<lbr/>

</xsl:for-each>

</td>

</tr>

</xsl:if>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>
Chris
"Dimitre Novatchev" <di******@tpg.c om.auschrieb im Newsbeitrag
news:45******** *************** @authen.yellow. readfreenews.ne t...
You forgot to provide your code

Cheers,
Dimitre Novatchev
"Christofer Dutz" <ch************ *@univativ.dewr ote in message
news:00******** **********@fe62 .usenetserver.c om...
>Hi,

I am having a small problem, that is driving me nuts.
My application reads some Xml and runs 2 Xsl Transformations to generate
HTML. As soon as my second XSL introduces some <br/tags, the
application crashes with the same error message I would get when writing
<brand no closing tag. To make everything a little stranger, even
<br></brseems to be bad while <lbr/is fine. Ive tried some other tag
names and the problem only appears with br-tags ... any ideas?

Regards,
Chris




Jan 2 '07 #3
Christofer Dutz wrote:
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

<xsl:template match="/profil">

<html>
Is that html element the root of your result tree? Then the XSLT
processor switches to output method html and serializes the result tree
as HTML for known HTML elements like the 'br' element so an empty
element will be serialized the HTML way which is <br>. 'lbr' is not a
known HTML element so it will be serialized the normal way as <lbr/or
<lbr></lbr>.

Thus if you want to have XML output even with a root element of 'html'
in the result tree then you need to specify
<xsl:output method="xml"/>
in the stylesheet.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 2 '07 #4
That did the trick ...
Geee ... I hate it when software starts acting too intelligent :(
html was indeed the root of my output document, but it's only an
intermediate format, seting the output format worked fine :) Thanks ;)

Chris

"Martin Honnen" <ma*******@yaho o.deschrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Christofer Dutz wrote:
><xsl:styleshee t version="1.0"
xmlns:xsl="htt p://www.w3.org/1999/XSL/Transform">

<xsl:templat e match="/profil">

<html>

Is that html element the root of your result tree? Then the XSLT processor
switches to output method html and serializes the result tree as HTML for
known HTML elements like the 'br' element so an empty element will be
serialized the HTML way which is <br>. 'lbr' is not a known HTML element
so it will be serialized the normal way as <lbr/or <lbr></lbr>.

Thus if you want to have XML output even with a root element of 'html' in
the result tree then you need to specify
<xsl:output method="xml"/>
in the stylesheet.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Jan 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7862
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 "languages" files and these are describes for things on my website. Example text looks like this:
6
12155
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 you and see if there are any improvments that i should make ;-) It should be fast and if possible compatible with todays modern browser-standards. It should be activated by the onload-event. This is my code, free for all to use:
7
19151
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 the browser. I even replaced all the newlines with <BR/> tags but eventhough I see the tags in my source, I don't get a line break in the output document. Any help would be greatly appreciated.
7
2744
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no tags will remain making the page safe (I have to convert the linefeeds to <BR>s because the Server.EncodeHTML does not do that it seems). The problem is that users can use a special tag when editing the top to specify an area of the tip that will...
2
2532
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 the charcontrols option and chr(13) with success.. was using the following code: Dim s As String = MyTextbox.Text
1
3171
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 the charcontrols option and chr(13) with success.. was using the following code: Dim s As String = MyTextbox.Text
9
43157
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 have also attempted singular variations of the CR/LF combination and even reversed the sequence without success. Is it possible that it may be encoded differently and if so what is it? Thanks
3
3377
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt, &gt ,&ltCompany&gt to display '<', '>' and '<Company>' respectively. But is there any freeware code available which could implement the above functionality without having to use &gt,&lt and such stuff???
7
3624
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 most people use when they write static code (some people use <br>, but with xhtml you are required to close all tags), IE6 simply breaks to the next line like it is supposed to. However, with <br></br>, which is what is sometimes generated by...
0
9196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9103
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2539
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2118
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.