473,324 Members | 2,002 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,324 software developers and data experts.

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 4307
You forgot to provide your code

Cheers,
Dimitre Novatchev
"Christofer Dutz" <ch*************@univativ.dewrote in message
news:00******************@fe62.usenetserver.com...
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.Collections;
using System.Configuration;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.XPath;
using System.Xml.Xsl;

/// <summary>
/// Zusammenfassungsbeschreibung für Class1
/// </summary>
namespace Transformers
{
public class XslTransformer : AbstractTransformer
{
protected XslCompiledTransform myXslTrans;

public XslTransformer()
{
}

override public void Setup(HttpRequest 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 XslCompiledTransform();
myXslTrans.Load(templateUri);
}

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

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

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

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

// Reset the memory stream so the "read-head" points to
// the beginning of the document
memStream.Position = 0;
// Create a new Dom Object from the byte junk in the memStream
XPathDocument outputDoc = new XPathDocument(memStream);
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:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/profil">

<html>

<body>

<h1>Mitarbeiter-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:choose>

<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="@bezeihnung"/>, <xsl:value-of
select="@universitaet"/>

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

</xsl:for-each>

</td>

</tr>

</xsl:if>

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

<tr>

<td>

<h3>Ausbildungen</h3>

</td>

<td>

<b>Ausbildungen</b>

</td>

</tr>

</xsl:if>

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

<tr>

<td>

<h3>Praxisreferenzen</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>:<xsl: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>Kenntnisse</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="@bezeichnung"/>

</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="@bezeichnung"/>

</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="@bezeichnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<lbr/>

</xsl:if>

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

<b>Betriebssysteme</b>

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

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

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

</xsl:for-each>

<lbr/>

</xsl:if>

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

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

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

</xsl:for-each>

<lbr/>

</xsl:if>

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

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

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

</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="@bezeichnung"/>

</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="@bezeichnung"/>

</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="@bezeichnung"/>

</xsl:for-each>

<lbr/>

</xsl:if>

<lbr/>

</xsl:if>

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

<b>Datenbanken</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="@bezeichnung"/>

</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="@bezeichnung"/>

</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="@bezeichnung"/>

</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="@bezeichnung"/><!-- - <xsl:choose>

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

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

<xsl:when test="@sprachbeherschungs-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.com.auschrieb im Newsbeitrag
news:45***********************@authen.yellow.readf reenews.net...
You forgot to provide your code

Cheers,
Dimitre Novatchev
"Christofer Dutz" <ch*************@univativ.dewrote in message
news:00******************@fe62.usenetserver.com...
>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:stylesheet 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*******@yahoo.deschrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP06.phx.gbl...
Christofer Dutz wrote:
><xsl:stylesheet 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 3 '07 #5

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

Similar topics

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...
7
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...
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...
3
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,...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.