Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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 March 24th, 2006, 11:57 AM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default select="<b>"

I'm not allowed to use these <> characters in the following code, so how to I get this to work?

  <xsl:variable name="reformatted_gdesc_1">
    <xsl:call-template name="replace_string">
      <xsl:with-param name="find" select="<b>"/>
      <xsl:with-param name="replace" select="''"/>
      <xsl:with-param name="string" select="MT[@N='gdesc']/@V"/>
    </xsl:call-template>
  </xsl:variable>

Thanks.

Al Dugan
www.atomicpark.com
__________________
Al Dugan
www.atomicpark.com
 
Old March 24th, 2006, 12:07 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need to escape using &-l-t-; for < and &-g-t-; for >. (Remove the dashes)
This will only work though if the text you are searching is actually text with those characters and not markup with a 'b' element.

--

Joe (Microsoft MVP - XML)
 
Old March 24th, 2006, 12:14 PM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried that and it still didn't work... gdesc is actually a meta tag which has html elements in it such as "<b>" and "</b>" -- given, it is the value of a meta tag, would thos elements be considered text or markup?

Al Dugan
www.atomicpark.com
 
Old March 24th, 2006, 12:34 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you post the XML that contains the relevant elements?

--

Joe (Microsoft MVP - XML)
 
Old March 24th, 2006, 12:54 PM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is my code which displays the value of the meta tag "gdesc" when it is available (Google Mini search results.) The value of "gdesc" is taken from a database and normally a common value would just be 255 characters or less of text such as "Since the debut of The Legend of Zelda in 1987, all of Links games have been the stuff of legends universally appealing adventures that emerged as beloved triumphs of gameplay, presentation, innovation, graphics and fun. In the ninth entry in the series" but occasionally these brief descriptions contain html elements so the values look like this "<b>FlowCharts & More</b> offers all the tools you need to quickly and easily create professional flow charts#44 organizational charts and business diagrams in minutes.<b>All the Tools You Need</b>A well-designed chart or diagram readily commu"


<xsl:if test="$show_res_snippet != '0'">
<br/>
<xsl:choose>
<xsl:when test="MT/@N = 'gdesc'">
<span class="grey_11">
<xsl:value-of disable-output-escaping='yes' select="MT[@N='gdesc']/@V"/><b>...</b>
</span><xsl:text disable-output-escaping='yes'>&lt;/td&gt;</xsl:text>
</xsl:when>
<xsl:otherwise>
<span class="grey_11">

<xsl:call-template name="reformat_keyword">
<xsl:with-param name="orig_string" select="S"/>
</xsl:call-template>
</span><xsl:text disable-output-escaping='yes'>&lt;/td&gt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>

This xml code works fine except when the meta tag values contain html elements... in which case it stops displaying the description as soon as it hits any html elements... so I thought by creating a variable that took out the html elements before displaying them my problems would be fixed, but I can't figure out how to strip out the html formatting.

Thank You for you help.

Al Dugan
www.atomicpark.com
 
Old March 24th, 2006, 01:13 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

What horrible XSLT... You realise this is IE specifice almost as disable output escaping won't work in Mozilla?

If you just want the text of an element rather than the markup just use <xsl:value-of select="path to element here"/>

What I'd like to see is the raw XML you are getting and an example of what output you desire.


--

Joe (Microsoft MVP - XML)
 
Old March 24th, 2006, 01:40 PM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I was scolded by someone else here for the XSLT as well. But in my defense, it's not really all mine... I learned it from GOOGLE! (I've just revised certain things they already had.)

As for the raw XML, I am getting this when a meta tag value starts with a <b> for ex.

<MT N="gdesc" V="<b"/>

While I get this, if there are no html elements:

<MT N="gdesc" V="TaxCut Premium w/ State 2005 is the ultimate tax solution. With its wealth of added tax advice and tools, TaxCut Premium ensures you get the most for your tax dollars. Includes all the forms you need to file Schedule C- sole proprietor/home-base"/>

I think it just might be easier if our .net programmer strips out the html elements before setting the value of the meta tag then I won't have to do any of this?

Al Dugan
www.atomicpark.com
 
Old March 24th, 2006, 01:48 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well it would be easier.
If you show me small sample of a full XML document that you receive and the sort of output you're looking for I'm happy to have a stab at it.

--

Joe (Microsoft MVP - XML)
 
Old March 24th, 2006, 02:01 PM
Authorized User
 
Join Date: Mar 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was hesitant to post the XML, but I don't know why since it is accessible on our public site...

Here is an example search result page: http://search.atomicpark.com/search?...=Google+Search

Taking out the proxystylesheet parameter gives you the raw xml:
http://search.atomicpark.com/search?...=Google+Search

Thank You. I appreciate your help.

Al Dugan
www.atomicpark.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
<select> </select> prabhash_singh11 PHP How-To 2 March 11th, 2008 09:08 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
HELP: XSL -> HTML <select selected=true> jedbartlett XSLT 4 October 7th, 2004 11:16 PM
<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.