473,414 Members | 1,598 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,414 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 4310
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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,...

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.