Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2010, 07:35 PM
Registered User
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl template killing my <sup>DHA</sup> why??

I'm fairly new to xml/xsl structures...sorry if this is a dumb question?

I have a xsl doc:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="content">
<xsl:if test="header_image/@path != ''">
<img src="{header_image/@path}" width="393" alt="{header_image/@alt}" /><br />
</xsl:if>
<xsl:if test="subheader/@path != ''">
<img src="{subheader/@path}" width="393" alt="{subheader/@alt}" />
</xsl:if>
<br />
<xsl:for-each select="article">
<p><a href="#{@id}"><xsl:if test="date != ''"><xsl:value-of select="date" /><br /></xsl:if><xsl:value-of select="title" /></a></p>
</xsl:for-each>
<xsl:for-each select="article">
<p><a name="{@id}"></a><xsl:if test="date != ''"><xsl:value-of select="date" /><br /></xsl:if><xsl:value-of select="title" /></p>
<p><xsl:copy-of select="text" /></p>

<p><a href="#top">Return to top ^</a></p>
</xsl:for-each>
<xsl:if test="footer != ''">
<span class="small"><xsl:copy-of select="footer" /></span><br /><br />
</xsl:if>
</xsl:template>
</xsl:stylesheet>

its pulled into a .asp page using .xml page with html here:

<?xml version="1.0" encoding="UTF-8"?>
<content>
<header_image path="" alt="" />
<subheader path="" alt="" />
<article id="1">
<date></date>
<title>Q: What is the difference between N<sup>DHA</sup> and N<sup>3</sup>?</title>
<text><b>A:</b> For a comparison chart of N<sup>DHA</sup> and N<sup>3</sup>, <a href="http://www.website.com/N_Chart.pdf">click here</a>
</text>
</article>
</content>

For a FAQ's type page that lists all articles at the top and click on it to reveal the answer down below..and has "back to top"

But inside the <title> tags I have <sup>DHA</sup> and they wont' show on page? But do fine in the <text> tags?

What am i doing wrong? Or what can I change to make the subscripts show in the <title> tags on the site?

any help is appreciated...thx
 
Old July 20th, 2010, 02:45 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You just need to change the <xsl:value-of> to a <xsl:copy-of>, exactly like is used to copy the text element.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old July 20th, 2010, 11:15 AM
Registered User
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Wierd

thx for the reply.

I tried changing the "value" to "copy" and it does allow the <sup> but it kills making the <title> click-able for the FAQ page.

But the funny thing is I changed the "value" to "copy" for the <date> tags...and in my xml with the html..I "cut" out the text with the <sup> from the <title> and "pasted it in the <date> tags and it works and is still clickable.

I guess I can go and do that to all my xml docs..but I still don't know why? Or it of course would of been easier to just change the 1 template doc..not all xml pages on the site pasted into the <date> instead of the <title>

Could've it been the if=test tag? maybe I'll go and try that switch on the title

-Dan
 
Old July 20th, 2010, 11:25 AM
Registered User
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default hmm

tried changing the if statement onto the title still didn't work....but for some reason it works it works on the date.

I guess I can go and change all the text in the <title> tags to <date> tags...but I still would like to know why? if anyone knows..otherwise this will work for now.

Thx
 
Old July 20th, 2010, 11:27 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

<xsl:copy-of> outputs an exact copy of the node you select, so it will also be outputting <title> or <text> element. If you don't want it to output them then you would use something like <xsl:copy-of select="title/node()"/>.

If this doesn't fix the problem then you would have to tell us what you want the output to actually look like before we could provide you with a solution.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old July 20th, 2010, 11:42 AM
Registered User
 
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fixed!!!!

ahahaaa!

That is it..it works perfect!
Sweet thx.

At least its showing all up correctly and linking. I'll have to go test all the pages across the site to make sure they all took it ok...but looks good.

great job...thx. this is a great site...I'll keep it.

-Dan





Similar Threads
Thread Thread Starter Forum Replies Last Post
embedded <xsl:element> into <xsl:with-param> petergoodman XSLT 2 July 9th, 2008 06:36 AM
Performance for <xsl:import> and <xsl:include> vikkiefd XSLT 2 April 16th, 2008 08:06 AM
doubt in using <xsl:template> rajatake XSLT 5 December 15th, 2006 08:09 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.