Calgarypuck Forums - The Unofficial Calgary Flames Fan Community
Old 10-24-2008, 07:12 PM   #1
Barnes
Franchise Player
 
Barnes's Avatar
 
Join Date: Aug 2005
Location: Violating Copyrights
Exp:
Default XML/XSL Help!

The dumbest little thing is tripping me up. This is the format of my xml file and there are 3 items in it.

Code:
<item>
<title>Blah Blah</title>
<date>Oct 10th</date>
<copy>Blah blah blah blah blah blah blah blah blah. Blurb blurb blurb blurb blurb blurb blurb. Bloob bloob bloob bloob bloob</copy>
</item>
The copy section needs to have paragraphs so it renders like this:

Blah blah blah blah blah blah blah blah blah.

Blurb blurb blurb blurb blurb blurb blurb.

Bloob bloob bloob bloob bloob


I need to put page breaks in except I can't figure out what will either create a page break or new paragraph.

Anyone have any idea? I have it rendering perfectly in all browsers other than that.
Barnes is offline   Reply With Quote
Old 10-24-2008, 07:28 PM   #2
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

What do you mean, the HTML code for a new line? < br / > ?
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 10-24-2008, 07:33 PM   #3
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

So something like this?

Code:
<xsl:for-each select="item">
 <p><xsl:value-of select="title"/></p>
 <p><xsl:value-of select="date"/></p>
 <p><xsl:value-of select="copy"/></p>
</xsl:for-each>
Though aren't paragraphs out of favour now? Or maybe:

Code:
<xsl:for-each select="item">
 <xsl:value-of select="title"/><br/>
 <xsl:value-of select="date"/><br/>
 <xsl:value-of select="copy"/><br/>
</xsl:for-each>
Or a DIV tag around them?
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 10-24-2008, 07:35 PM   #4
Barnes
Franchise Player
 
Barnes's Avatar
 
Join Date: Aug 2005
Location: Violating Copyrights
Exp:
Default

Quote:
Originally Posted by photon View Post
What do you mean, the HTML code for a new line? < br / > ?
It just gets ignored when I use any html tag within the <copy> section.

I can get the title date and copy as new lines (in at table specifically) but the content within the copy tag needs to be separated. In the code example above, I need each sentence in <copy> on a new line.

Last edited by Barnes; 10-24-2008 at 07:39 PM.
Barnes is offline   Reply With Quote
Old 10-24-2008, 07:40 PM   #5
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

Hm, I've never used copy xsl:copy before so not sure if there's any rules around that or not.
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 10-24-2008, 07:46 PM   #6
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

So you want a carriage return and new line together, correct?
__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
Rathji is offline   Reply With Quote
Old 10-24-2008, 07:50 PM   #7
Barnes
Franchise Player
 
Barnes's Avatar
 
Join Date: Aug 2005
Location: Violating Copyrights
Exp:
Default

Sorry, I'm not explaining this well. I will have a cup of coffee, a smoke and regroup.

It's such a stupid, small thing that is keeping me from finishing up a project. It would be like rebuilding a car and not being able to figure out where to put the gas.
Barnes is offline   Reply With Quote
Old 10-24-2008, 08:03 PM   #8
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

This syntax that should get you what you need.

This might help you understand why a newline might not be working properly.

If it doesn't there is more documentation on the w3 site that will further explain a solution.



BTW I know almost nothing about creating XML documents, for the most part my use of them has been parsing out info, but w3school is my source for when I do
__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
Rathji is offline   Reply With Quote
Old 10-24-2008, 08:42 PM   #9
Barnes
Franchise Player
 
Barnes's Avatar
 
Join Date: Aug 2005
Location: Violating Copyrights
Exp:
Default

Yeah I've read most of the w3school content on xml and xslt unfortunately.

Okay, here goes.

An MFC application that will be used by our support department creates and uploads the XML file.

The XML file contains important information for our customers in the form of a news window which is really a custom IE 6 instance launched from our application and rendered by the XSL file to look nice.

The XML file looks like this:
Code:
<item>
<title>New Version Available</title>
<date>Oct 20th</date>
<copy>We are pleased to announce version 2.0 of our software. This new version includes many new enhancements as well as bug fixes. This update can be downloaded by launching your software update. Training is also available. Contact your sales person for more info.</copy>
</item>
The XSL style sheet that renders it looks something like this:
Code:
<table>
<tr>
<td><xsl:value-of select="title"/></td>
</tr>
<tr>
<td><xsl:value-of select="date"/></td>
</tr>
<tr>
<td><xsl:value-of select="copy"/></td>
</td>
<table
The result in the browser is this:

New Version Available

Oct 20th

We are pleased to announce version 2.0 of our software. This new version includes many new enhancements as well as bug fixes. This update can be downloaded by launching your software update. Training is also available. Contact your sales person for more info.


I need it to look like this in the browser:

New Version Available

Oct 20th

We are pleased to announce version 2.0 of our software. This new version includes many new enhancements as well as bug fixes.

This update can be downloaded by launching your software update.

Training is also available.

Contact your sales person for more info.


How do I get the separate paragraphs?
Barnes is offline   Reply With Quote
Old 10-24-2008, 08:52 PM   #10
Rathji
Franchise Player
 
Rathji's Avatar
 
Join Date: Nov 2006
Location: Supporting Urban Sprawl
Exp:
Default

Couldn't you embed HTML inti XML and just use a HTML line break?

Not that I would know how to do that, but I seem to recall dealing with HTML embeded inside an XML file, so I imagine it is possible.
__________________
"Wake up, Luigi! The only time plumbers sleep on the job is when we're working by the hour."
Rathji is offline   Reply With Quote
Old 10-24-2008, 09:10 PM   #11
photon
The new goggles also do nothing.
 
photon's Avatar
 
Join Date: Oct 2001
Location: Calgary
Exp:
Default

The copy's going to be reproduced exactly as is, if you want line breaks inside the copy then you're going to have to do something to have the XML parser ignore the HTML in it.

I think you use the CDATA tag to do that:

Code:
<![CDATA[We are pleased to announce version 2.0 of our software.<br/><br/>This new version includes many new enhancements as well as bug fixes.<br/>This update can be downloaded by launching your software update.<br/>Training is also available.<br/>Contact your sales person for more info.]]>
You may need to add a disable-output-escaping="yes" attribute to the xsl:value-of tag.

EDIT: Or use a tag:

Code:
<td><xsl:cdata><xsl:value-of select="copy"/></xsl:cdata></td>
__________________
Uncertainty is an uncomfortable position.
But certainty is an absurd one.
photon is offline   Reply With Quote
Old 10-24-2008, 09:17 PM   #12
Barnes
Franchise Player
 
Barnes's Avatar
 
Join Date: Aug 2005
Location: Violating Copyrights
Exp:
Default

Quote:
Originally Posted by Rathji View Post
Couldn't you embed HTML inti XML and just use a HTML line break?

Not that I would know how to do that, but I seem to recall dealing with HTML embeded inside an XML file, so I imagine it is possible.
Using the html requires a closing tag or else it kicks back an error. Using <p>fnvdf</p> or <br>fvffvfvdv</br> does nothing.

Seems like it should be so easy.

I may have to go with:
Code:
<item>
<title>New Version Available</title>
<date>Oct 20th</date>
<copy_1>We are pleased to announce version 2.0 of our software. This new version includes many new enhancements as well as bug fixes.</copy_1> <copy_2>This update can be downloaded by launching your software update.</copy_2>
<copy_3> Training is also available.</copy_3>
<copy_4> Contact your sales person for more info.</copy_4>
<copy_5></copy_5>
</item>
and:

Code:
<table>
<tr>
<td><xsl:value-of select="title"/></td>
</tr>
<tr>
<td><xsl:value-of select="date"/></td>
</tr>
<tr>
<td><xsl:value-of select="copy_1"/><br/>
<xsl:value-of select="copy_1"/><br/>
<xsl:value-of select="copy_2"/><br/>
<xsl:value-of select="copy_3"/><br/>
<xsl:value-of select="copy_4"/><br/>
<xsl:value-of select="copy_5"/><br/></td>
</tr>
<table
Barnes is offline   Reply With Quote
Old 10-24-2008, 09:19 PM   #13
Barnes
Franchise Player
 
Barnes's Avatar
 
Join Date: Aug 2005
Location: Violating Copyrights
Exp:
Default

Quote:
Originally Posted by photon View Post
The copy's going to be reproduced exactly as is, if you want line breaks inside the copy then you're going to have to do something to have the XML parser ignore the HTML in it.

I think you use the CDATA tag to do that:

Code:
<![CDATA[We are pleased to announce version 2.0 of our software.<br/><br/>This new version includes many new enhancements as well as bug fixes.<br/>This update can be downloaded by launching your software update.<br/>Training is also available.<br/>Contact your sales person for more info.]]>
You may need to add a disable-output-escaping="yes" attribute to the xsl:value-of tag.

EDIT: Or use a tag:

Code:
<td><xsl:cdata><xsl:value-of select="copy"/></xsl:cdata></td>
Hmmm... that may be it. I will try it out. Thanks!
Barnes is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:17 AM.

Calgary Flames
2024-25




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Calgarypuck 2021 | See Our Privacy Policy