473,320 Members | 1,916 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,320 software developers and data experts.

Displaying XML document in ASP.NET page using XSL Transform

I have an XML document that I am trying to display in my ASP.NET page.

I am using an XSL Transform to display repeating XML data in a
specific format.

It reads the data, and displays it on my page, but there's a problem.

It runs all the data together on one line.

The XSL file is as follows:

-- begin xml ---

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/guestbook">
<xsl:apply-templates select="guestbook" />
<xsl:value-of select="name" />
<xsl:apply-templates select="guestbook" />
<xsl:value-of select="comment" />
</xsl:template>
</xsl:stylesheet>

-- end xml ---

I've tried putting <BR> in between the name and comment in the XSL
file and ASP.NET strips it out. I view the source in my browser and
for some reason ASP.NET just sends all the XML data as one string on
one line. I can't even figure out how to put spaces between the two
items.

I'd like to see:

Joe Blow

Hello, My Name is Joe.

Instead, what I get is:

Joe BlowHello, My Name is Joe.

Please help!!!
Nov 18 '05 #1
2 2008
The XSL transform document requires exact XML formatting. Your <BR>
will need to change to <BR/>. Other than that, I would think that
would work. As for the space, you need to use the XSL variant of a
space. Somthing like #160; or something like that. (been a while for
xsl for me)

On 7 Apr 2004 19:20:58 -0700, ba******@yahoo.com (Barry Anderberg)
wrote:
I have an XML document that I am trying to display in my ASP.NET page.

I am using an XSL Transform to display repeating XML data in a
specific format.

It reads the data, and displays it on my page, but there's a problem.

It runs all the data together on one line.

The XSL file is as follows:

-- begin xml ---

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/guestbook">
<xsl:apply-templates select="guestbook" />
<xsl:value-of select="name" />
<xsl:apply-templates select="guestbook" />
<xsl:value-of select="comment" />
</xsl:template>
</xsl:stylesheet>

-- end xml ---

I've tried putting <BR> in between the name and comment in the XSL
file and ASP.NET strips it out. I view the source in my browser and
for some reason ASP.NET just sends all the XML data as one string on
one line. I can't even figure out how to put spaces between the two
items.

I'd like to see:

Joe Blow

Hello, My Name is Joe.

Instead, what I get is:

Joe BlowHello, My Name is Joe.

Please help!!!


Nov 18 '05 #2
First of all, that's all your XSLT will ever do irrespective of the XSLT
engine or framework.

You need to either generate HTML (the preferred method of output for XSLT
when trying to present data) or add the newline characters in yourself as
unicode character codes:

eg. newline is &#xA; [I think]

Try this example to see what should be happening (generates HTML):

XML:

<root>
<guestbook>
<entries>
<entry>
<name>Joe</name>
<comment>Nice place</comment>
</entry>
<entry>
<name>Jan</name>
<comment>Thanks for the lovely food</comment>
</entry>
<entry>
<name>Tim</name>
<comment>Thanks</comment>
</entry>
</entries>
</guestbook>
</root>

XSLT:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
<!-- Generate the root html node -->
<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>
<!-- Match for the guestbook element -->
<xsl:template match="guestbook">
<h1>My Guestbook</h1>
<!-- Allow the default templates to process the remainder of the
document -->
<xsl:apply-templates/>
</xsl:template>
<!-- Match for the entry element -->
<xsl:template match="entry">
<h2>
<xsl:value-of select="name" />'s comment was:
</h2>
<p>
<xsl:value-of select="comment" />
</p>
<xsl:if test="not(position()=last())">
<hr/>
</xsl:if>
<!-- No need to apply further templates -->
</xsl:template>
</xsl:stylesheet>

Gives (XHTML):

<html>
<h1>My Guestbook</h1>
<h2>Joe's comment was:
</h2>
<p>Nice place</p>
<hr />
<h2>Jan's comment was:
</h2>
<p>Thanks for the lovely food</p>
<hr />
<h2>Tim's comment was:
</h2>
<p>Thanks</p>
</html>

Hope this helps.

Chris.

"Barry Anderberg" <ba******@yahoo.com> wrote in message
news:9d**************************@posting.google.c om...
I have an XML document that I am trying to display in my ASP.NET page.

I am using an XSL Transform to display repeating XML data in a
specific format.

It reads the data, and displays it on my page, but there's a problem.

It runs all the data together on one line.

The XSL file is as follows:

-- begin xml ---

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/guestbook">
<xsl:apply-templates select="guestbook" />
<xsl:value-of select="name" />
<xsl:apply-templates select="guestbook" />
<xsl:value-of select="comment" />
</xsl:template>
</xsl:stylesheet>

-- end xml ---

I've tried putting <BR> in between the name and comment in the XSL
file and ASP.NET strips it out. I view the source in my browser and
for some reason ASP.NET just sends all the XML data as one string on
one line. I can't even figure out how to put spaces between the two
items.

I'd like to see:

Joe Blow

Hello, My Name is Joe.

Instead, what I get is:

Joe BlowHello, My Name is Joe.

Please help!!!
Nov 18 '05 #3

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

Similar topics

1
by: Barry Anderberg | last post by:
I have an XML document that I am trying to display in my ASP.NET page. I am using an XSL Transform to display repeating XML data in a specific format. It reads the data, and displays it on my...
14
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file...
0
by: Wynter | last post by:
RE: from Displaying a Document using the ASPNET user account to the Client Browser discussion (3/2/2004 Buddy Thanks for helping me on getting the document to display. But now I am left with a...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
0
by: Anthony Harkness-Gripe | last post by:
This is a very simple XSLT, and I'm doing it ways that I've had work before, but it's not displaying HTML. Is there a flaw in my logic? C#:...
7
by: DazedAndConfused | last post by:
I have a 8.5 x 11 landscape document with about 1/4 inch of space on the left and right where there is no print. The document displays perfect in print preview, but when I print it, about 1/2 inch...
5
by: Lis | last post by:
Hi, I have inconsistent behavior of document() function which I hope someone can explain. I have Windows Service (runs as LocalSystem) that perform some Xslt transformation. In the stylesheet...
3
by: Rusty | last post by:
Hi, our intranet web site needs to add this feature. I've got the components but just need the last step to get it going. Here's the setup. 1) a user clicks on a link which calls a web service...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.